html - Why is it flickering on hover? -
i have encountered problem. have made hover transition. when mouse moving on image flickers between hovered , unhovered state. when mouse still on image works how should. can find problem please?
html
<div class="belowcont"> <div class="circles"> <img class="circleimg" src="circle1.jpg"/> <p class="circletext"> multi award winning film </p> </div> <div class="circles"> <img class="circleimg" src="circle2.jpg" /> <p class="circletext"> story of shanes life </p> </div> <div class="circles"> <img class="circleimg" src="circle3.jpg"/> <p class="circletext">set in east midlands </p> </div> </div>
css
.belowcont { width:100%; height:200px; border:1px dashed black; margin-top:2px } .circles { width:180px; height:180px; background:url(circles.png); background-size:100% ; background-image:no-repeat;; border-radius:50%; margin-left:120px; margin-top:10px; float:left; margin-left:120px; margin-top:10px; float:left; } .circleimg { width:180px; height:180px; border-radius:50%; } .circleimg:hover { width:180px; height:180px; border-radius:50%; position:absolute; z-index:-100; transition:all 1s linear; } .circleimg:hover ~ .circletext{ visibility:visible; } .circletext { color:white; width:160px; text-align:center; margin:80px auto; visibility:hidden;}
i'm unsure why it's doing that, can offer different solution have never experienced problem.
instead of using visibility: visible
try setting default text class to:opacity: 0
.
then on hover:
opacity: 1; transition: opacity 1s;
i've taken out bits of code aren't of use , absolutely positioned text within image.
it seems better. have fiddle positioning , you'll go. (pun intended 'fiddle about')
http://jsfiddle.net/fjgu0s4q/1/
edit: after little more thinking why flickered, seems method of moving text on image on hover. when you're hovering on image check (pseudo code)
if mouse move == true if hovering on element // specified task end if end if
so if move 1 pixel has check again, , again, has move text default state on move. since method wasn't organic way of doing it, seems why flickered. moving text , down checking state of mouse positioning.
Comments
Post a Comment