CSS size transition to stay inside parent div

Posted by IlyaD on Stack Overflow See other posts from Stack Overflow or by IlyaD
Published on 2012-09-18T15:19:20Z Indexed on 2012/09/18 15:37 UTC
Read the original article Hit count: 426

Filed under:
|
|
|

I want to have an image frame that when I hove over it the image inside will zoom in a little (I am using size transition), but the frame will stay the same size.

What happens now that even if the frame has a fixed width and height it is stilled zoomed with the image

HTML:

<div class="img-wrapper">
  <img class="thumbnail" src="http://placekitten.com/400/200">
</div>

and CSS

.img-wrapper {
  width: 400px;
}
.thumbnail {
  width: 400px;
}

.thumbnail {
  -webkit-transition: all 0.2s ease-out;
  -moz-transition: all 0.2s ease-out;
  transition: all 0.2s ease-out;
}

.thumbnail:hover {
  width: 500px;

  -webkit-transition: all 0.2s ease-out;
  -moz-transition: all 0.2s ease-out;
  transition: all 0.2s ease-out;
}

http://codepen.io/pen/KCJny

© Stack Overflow or respective owner

Related posts about css

Related posts about css3