我在使用时遇到问题 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>
Run Code Online (Sandbox Code Playgroud)
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); }
Run Code Online (Sandbox Code Playgroud)
缩放图像时如何防止溢出?
我的代码有什么问题?
提前致谢...
你需要设置position: absolute为img
img {width:200px;
height:200px;
transition:transform 1s linear;
position: absolute;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7718 次 |
| 最近记录: |