html - CSS3 - Transform Issues - Div positioning -
i'm trying create container animates...
- on hover background image transform scale (zooms in) while opacity layer appears on image.
- caption translates in right "learn more" caption.
my issue when try absolute position .caption not appear in front of elements within container. seems position:absolute being overwritten something. when try debug can see it's behind container elements. desired affect .caption position in front of container elements.
does know i'm doing wrong here?
<div class="container"> <img id="image-zoom" src="http://s16.postimg.org/cr851jb5h/services_img_demo.jpg"/> <span class="opacity-layer scale-opacity-layer"></span> <div class="caption"><a href="#">learn more+</a></div> </div> /* overflow prevent scaled image expanding width of it's container */ .container { cursor: pointer; height: 254px; /* controls height of container */ width: 381px; /* controls width of container */ float: left; margin: 5px; position: relative; overflow: hidden; } /** on hover image scale (zoom) 1.4 of size **/ .container:hover #image-zoom { -moz-transform: scale(1.4); -o-transform: scale(1.4); -webkit-transform: scale(1.4); transform: scale(1.4); } /** controls transition speed of opacity-layer appearing **/ .container img { position: absolute; left: 0; -webkit-transition: 300ms ease-out; -moz-transition: 300ms ease-out; -o-transition: 300ms ease-out; -ms-transition: 300ms ease-out; transition: 300ms ease-out; } .container .opacity-layer { background-color: rgba(0,0,0,0.8); /* controls color of opacity-layer */ position: absolute; z-index: 50; -webkit-transition: 300ms ease-out; -moz-transition: 300ms ease-out; -o-transition: 300ms ease-out; -ms-transition: 300ms ease-out; transition: 300ms ease-out; left: 0; } .container .scale-opacity-layer { opacity: 0; /* controls default opacity */ width: 400px; /* controls width of opacity layer */ height: 300px; /* controls height of opacity layer */ } /** fade opacity-layer :hover behaviour **/ .container:hover .scale-opacity-layer { opacity: 0.3; /* controls opacity of opacity-layer */ } /** container caption **/ .caption { posiiton:absolute; height:100px; width:100px; left:100px; background-color:red; z-index:100; }
see pen occp - services container animation on hover darius e. shojaei (@stinkytofu3311) on codepen.
wrong spell of "position" on class .caption
.caption { position: absolute; height:100px; width:100px; left:100px; background-color:red; z-index:100; }
Comments
Post a Comment