-
-
Save CBoJI/3595925 to your computer and use it in GitHub Desktop.
смена цвета картинок при наведении с серого на цветной. используется 1 картинка, css, thumbnail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sorl.thumbnail import get_thumbnail | |
partners = [] | |
total_width = 0 | |
for partner in PartnerItem.objects.filter(published=True).order_by('?'): | |
im = partner.get_first_picture() | |
tmp = get_thumbnail(im.image, 'x64', crop='center center') | |
total_width += tmp.width | |
if total_width > 960: | |
break | |
else: | |
gray = get_thumbnail(im.image, 'x64', crop='center center', colorspace='GRAY') | |
partners.append({ | |
'title': partner.title, | |
'link': partner.link, | |
'im_gray': gray, | |
'im_colored': tmp, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.partner_link:hover .partner_gray { | |
display: none; | |
} | |
.partner_link:hover .partner_color { | |
display: block; | |
} | |
.partner_gray { | |
} | |
.partner_color { | |
display: none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% for partner in partners %} | |
<div class="item"> | |
<div class="gray-block"> | |
<a class="partner_link" href="{{ partner.link }}"> | |
<img class='partner_gray' src="{{ partner.im_gray.url }}" width='{{ partner.im_gray.width }}' height="{{ partner.im_gray.height }}" alt="{{ partner.title }}"/> | |
<img class='partner_color' src="{{ partner.im_colored.url }}" width='{{ partner.im_colored.width }}' height="{{ partner.im_colored.height }}" alt="{{ partner.title }}"/> | |
</a> | |
</div> | |
</div> | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment