Can CSS be used to change an image's color for active & hover? -
i'm working shape5.com corporate response joomla template , been asked make change color of 4 icons social media in upper right-hand corner. demo of template can found here:
http://www.shape5.com/demo/corporate_response/
their css each icon looks template.css file. i'm including first icon keep brief, rss:
#s5_rss { height:23px; width:22px; background:url(../images/rss.png) no-repeat top left; cursor:pointer; margin-left:8px; float:right; } #s5_rss:hover { background:url(../images/rss.png) no-repeat bottom left; }
the rss.png here:
http://www.shape5.com/demo/corporate_response/templates/corporate_response/images/rss.png
i've been asked use css change active/hover color red. i'm not sure if can done css or not. can it? or require new .png file created image designer desired red color?
i'd understand why rss.png file has 2 images of icon inside of @ different shades , how css toggle between them know use hover? special .png file allows this, perhaps in different format .png files? thanks!
the image known sprite image: single image file consisting of multiple sprites apply single background image, , position according constraints set width
, height
properties on element. it's regular png image , not intrinsically different other png images.
as changing color of image red, not can css alone depending on mean "changing color" — safest bet modify image add new sprite desired color. since it's regular png image it's simple matter of extending canvas 23 pixels down, rendering new sprite in space that's created, , modifying css looks this:
#s5_rss:hover { background:url(../images/rss.png) no-repeat center left; } #s5_rss:active { background:url(../images/rss.png) no-repeat bottom left; }
you can replace background:url(../images/rss.png) no-repeat
portion background-position:
in :hover
, :active
rules you're modifying background position when using sprite in css:
#s5_rss:hover { background-position:center left; } #s5_rss:active { background-position:bottom left; }
Comments
Post a Comment