i have a problem when using transform: scale();
basically, i'm using this scale on Image that has overflow:hidden
check this fiddle out for live action : https://jsfiddle.net/ns3vm3x6/
HTML
<div id="container1">
<img src="http://lorempixel.com/400/200">
</div>
<p> i want this image to scale just like #example no. 2. how to achive this one? </p>
<br><br>
<div id="container2">
<img src="http://lorempixel.com/400/200">
</div>
CSS
#container1 {width:100%; height:200px; border:2px solid red;
overflow-x:scroll; overflow-y:hidden; white-space:no-wrap; }
#container2 {width:100%; height:200px; border:2px solid red; white- space:no-wrap; }
img {width:200px; height:200px; transition:transform 1s linear; }
img:hover {transform:scale(2); }
How to prevent that overflow when scaling image?
what's wrong with my code?
thanks in advance...
You need to set position: absolute
for img
img {width:200px;
height:200px;
transition:transform 1s linear;
position: absolute;
}
JSFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With