在使用 transform: scale();
时遇到了问题。
基本上,我在一个具有 overflow:hidden
的图像上使用此缩放效果。
请查看此链接以获取实时演示: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); }
如何防止缩放图像时出现溢出?
我的代码有什么问题吗?
提前感谢...
img
加上position: absolute
,这是你想要的吗? @ChingChing JSFiddle - Pedram