What I'm Doing: Taking this:
#prod-img {
width: 33%;
max-width: 33%;
margin-right: 3%;
display: inline-block;
float: left;
}
and trying to transition to this:
#prod-img:hover, #prod-img:active{
width: auto;
float: none;
display: block;
max-width: 100%;
height: auto;
margin-left: auto;
margin-right: auto;
}
Here is a jsFiddle of what this looks like in action.
Problem: CSS Transitions from a percent to initial is great unless you can't use max-width. I need to use max-width to actually cap the width so I can't do what is suggested here. I can't use width because all of the images have different widths.
What I've Tried: Using width, margin, and height. I also tried using jQuery .addClass()
and .css()
but absolutely nothing happened when I moused over.
Desired Result: A silky-smooth CSS transition from small and floating left to large and centered on images of any size.
Here's what the HTML looks like (I'm using angular to spool off lots of these images):
<div>
<img id="prod-img" src="{{product.url}}" alt="{{product.name}}" />
</div>