javascript - How to create a smooth zoom and display an overlay when another HTML element gets hovered? -
1st problem: trying display text overlay when "point" class gets hovered, me works display when "caption" class gets hovered, how fix it?
2nd problem: need create smooth zoom in image when "point" class gets hovered, how can it?
demo: http://jsfiddle.net/0qgcn2uu/12/
html:
<div class="caption"> <span class="point"></span> <img src="http://www.blasdale.com/pictures/2007/hendon/thumbs/img_3337.jpg" /> <div class="caption__overlay"> <div class="caption__overlay__content"> <img id="hello" class="caption__media" src="http://2.bp.blogspot.com/-th7atkz55uw/voatqsmgt4i/aaaaaaaaaum/bb199rdzmue/s1600/alone.png" /> </div> </div> </div> css:
.caption { position: relative; overflow: hidden; -webkit-transform: translatez(0); } .caption::before { content: ' '; position: absolute; top: 0; right: 0; bottom: 0; left: 0; background: transparent; transition: background .35s ease-out; } .captionhover::before { background: rgba(248, 214, 215, .5); } /* want when hover on circle, image overlay, doesn't work */ .point:hover: + .caption::before { background: rgba(248, 214, 215, .5); } .point { position: absolute; display: block; height: 25px; width: 25px; border-radius: 30px; background-color: black; } .caption__overlay { position: absolute; top: 0; right: 0; bottom: 0; left: 0; padding: 10px; color: white; -webkit-transform: translatey(100%); transform: translatey(100%); transition: -webkit-transform .35s ease-out; transition: transform .35s ease-out; } .caption:hover .caption__overlay { -webkit-transform: translatey(0); transform: translatey(0); } .caption { display: inline-block; } .caption__media{ max-width: 100%; } jquery:
$(document).ready(function() { $(".point").mouseenter(function() { $('.caption').addclass('captionhover'); }); $('.point').mouseleave(function() { $('.caption').removeclass('captionhover'); }); });
all need adjacent sibling selector, general sibling selector , ftransform
*{ box-sizing: border-box } figure{ overflow: hidden; width: 250px; height: 250px; margin: 50px auto; z-index:1; position: relative } figure span{ display: block; width: 16px; height:16px; border-radius: 50%; background: black; z-index: 2; position: absolute; top: 10px; left: 10px; cursor: pointer } figure img, figure figcaption{ -webkit-transition: 1s ease } figure figcaption{ position: absolute; top: 100%; z-index: 2; width: 100%; left: 0; text-align: center; color: white } figure span:hover + img{ -webkit-transform: scale(2,2) } figure span:hover ~ figcaption{ top: 50% } <figure> <span class=point></span> <img src="http://www.blasdale.com/pictures/2007/hendon/thumbs/img_3337.jpg" /> <figcaption>hello!</figcaption> </figure>
Comments
Post a Comment