html - Make a clickable, animated hover using css only -
the point making aside
element enter when hover on image, using css, also, let children accept click events.
so far have functioning animated hover, has button in , button does act on click events. have used pointer-events: none
on sliding aside
element, because otherwise animation jumpy point of breaking, so, pointer-events: none
gets out of way , animation smooth , persistent long you're hovering.
the problem occurs when hover on button. make aside
transition out (see fiddle, it's better broken english).
i'm looking way prevent aside
returning initial, hidden position. , challenge of course, using css only!
here code (it's in fiddle):
html:
<div class="thumbnail"> <img src="http://i59.tinypic.com/10cvw8y.jpg" class="template-img"> <aside tab-index="1" class="hover"> <button class="button" onclick="alert('wow')">click me</button> </aside> </div>
css:
.thumbnail { position: relative; overflow: hidden; } .template-img { width: 100%; height: 100%; } .template-img:hover ~ .hover { transform: translatex(0); } .template-img:focus { pointer-events: none; } .template-img:focus ~ .hover { transform: translatex(0); transition: none; } .hover { position: absolute; top: 0; width: 100%; height: 100%; padding-top: 15%; transform: translatex(-100%); transition: transform .4s ease-out; pointer-events: none; background: rgba(255, 0, 0, 0.4); z-index: 10; } .button { pointer-events: auto; }
adding style below seems fixed problem
.hover:hover { transform: translatex(0); }
forcing animation run when hovering content well
here's fiddle
Comments
Post a Comment