在我的网页上,我想放置一个图像,当鼠标指针悬停在该图像上时,会出现放大版本。
问问题
95478 次
3 回答
8
根据评论中对要求的进一步解释更新了 CSS 解决方案
<div class="effectback">
<img class="effectfront" src="https://farm8.staticflickr.com/7042/6873010155_d4160a32a2.jpg" />
</div>
attribution<br/>
https://secure.flickr.com/photos/34022876@N06/6873010155/sizes/m/in/photostream/
.effectback {
display: block;
background: url('https://farm8.staticflickr.com/7042/6873010155_d4160a32a2_s.jpg') no-repeat;
margin: 0 auto;
}
.effectfront {
opacity: 0;
border: none;
margin: 0 auto;
}
.effectfront:hover {
opacity: 1;
transition: all 0.3s;
-webkit-transition: all 0.3s;
}
基于原始问题的原始css解决方案
CSS 解决方案
.effectscale {
border: none;
margin: 0 auto;
}
.effectscale:hover {
-webkit-transform: scale(1.2);
-moz-transform: scale(1.2);
-o-transform: scale(1.2);
transform: scale(1.2);
transition: all 0.3s;
-webkit-transition: all 0.3s;
}
于 2013-08-27T02:57:00.437 回答
7
<img src="..." onmouseover="this.width='someWidth'; this.height='someHeight'" onmouseout="this.width='originalWidth'; this.height='originalHeight'">
于 2013-08-27T02:57:13.970 回答
0
试试这个:
<html>
<head>
<style>
.container{
overflow:hidden;
width:300px;/*change this to whatever you want*/
height:150px;/*change this to whatever you want*/
/*Of course, to get the desired effect, the size of the image "<img>" below must be larger than the size mentioned above*/
}
.container:hover{
overflow:visible
}
</style>
</head>
<body>
<div class='container'><img src='myImage.png'/></div>
</body>
</html>
于 2016-09-19T18:21:17.397 回答