0

I'm trying to create a container that animates...

  1. On Hover background image transform scale (zooms in) while opacity layer appears over image.
  2. Caption translates in from right with "Learn More" caption.

My issue is that when i try to absolute position my .caption it does not appear in front of all the elements within the container. It seems the position:absolute is being overwritten by something. When i try to debug i can see that it's behind the container elements. The desired affect would be the .caption position in front of the container elements.

Does anybody know what 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 will prevent the scaled image from expanding the 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 the image will scale (zoom) to 1.4 of its 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 the opacity-layer appearing **/
.container img {
    position: absolute;
    left: 0;
        -webkit-transition: all 300ms ease-out;
        -moz-transition: all 300ms ease-out;
        -o-transition: all 300ms ease-out;
        -ms-transition: all 300ms ease-out; 
    transition: all 300ms ease-out;
}
.container .opacity-layer {
    background-color: rgba(0,0,0,0.8); /* Controls the color of the opacity-layer */
    position: absolute;
    z-index: 50;
        -webkit-transition: all 300ms ease-out;
        -moz-transition: all 300ms ease-out;
        -o-transition: all 300ms ease-out;
        -ms-transition: all 300ms ease-out; 
        transition: all 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 the opacity-layer */
}

/**        Container Caption          **/
.caption {
  posiiton:absolute;
  height:100px;
  width:100px;
  left:100px;
  background-color:red;
  z-index:100;
}
See the Pen OCCP - Services Container Animation on Hover by Darius E. Shojaei (@stinkytofu3311) on CodePen.

1
  • in your code there is a small spell mistake you have written as positon instead of position on class .caption just correct it will solve issue. Commented Mar 7, 2016 at 7:31

1 Answer 1

2

wrong spell of "position" on class .caption

.caption {
  position: absolute;
  height:100px;
  width:100px;
  left:100px;
  background-color:red;
  z-index:100;
}

jsFiddle

Sign up to request clarification or add additional context in comments.

1 Comment

oh... doh! That's what i get for coding all day. Thanks m8. I thought i had lost my mind..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.