javascript - Smooth Transition On Hovering -
i've been working on finding way change out <img id="repair" src="http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/repair.svg"
using :hover
image called repair_h.svg
. doing placing :hover
on #repair
#repair :hover
, giving repair background-image:url
not working , think there few reasons why.
that initial process...since did not work did research on how achieve correctly , found way achieve js. way less hackie other css , html solutions looking into.
using js ended working great purpose of need done although there's 1 piece i'd add , i'm not quite sure how it.
i'd add smooth transition between image's when hovered on.
link current build http://kapena.github.io/pp_web/ icon working on here called repair services
html
<li> <a href="#"> <img id="repair" src="http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/repair.svg" onmouseover="this.src='http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/hov/repair_h.svg'" onmouseout="this.src='http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/repair.svg'" border="0" alt="about plumbing repairs in honolulu hawaii"> </img> </a> </li>
js
function hover(element) { element.setattribute('src', 'http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/hov/repair_h.svg'); } function unhover(element) { element.setattribute('src', 'http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/repair.svg');
also if of have suggestions on away perform entire task without js , entirely html , css i'd open seeing how you'd :)
thanks
you can markup , css only:
html:
<a href="#"> <img id="repair" src="http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/repair.svg" border="0" alt="about plumbing repairs in honolulu hawaii" /> </a>
css:
a { background:url('http://d3vi9nkvdbmq5l.cloudfront.net/service-icons/hov/repair_h.svg') 0 0 no-repeat; width:150px; margin:0; padding:0; float:left; } img { opacity:1; transition:opacity .5s; float:left; } a:hover img { opacity:0; transition:opacity .5s; }
Comments
Post a Comment