html+css3鼠标移上图片放大遮罩

2025-12-29 19:47:40

1、准备好需要用到的图标。

html+css3鼠标移上图片放大遮罩

2、新建html文档。

html+css3鼠标移上图片放大遮罩

3、书写hmtl代码。

<div id="wrapper">

 <div class="main_img"> <img src="images/pic_01.jpg">

  <div class="show"> <span class="imgArea"> <a title="观看视频" href="#">观看视频</a> </span> </div>

 </div> 

</div>

html+css3鼠标移上图片放大遮罩

4、初始化css代码。

<style>

body { text-align: center; background: none repeat scroll 0 0 #FFFFFF; color: #222222; font-family: "微软雅黑"; line-height: 1.6; }

a { font-family: arial, "Hiragino Sans GB", "Microsoft Yahei", sans-serif; font-size: 14px; color: #333; text-decoration: none; }

</style>

html+css3鼠标移上图片放大遮罩

5、书写css代码。

#wrapper { max-width: 260px; width: 100%; margin: 0px auto; margin-top: 10px; }

.main_img { height: 180px; width: 250px; overflow: hidden; position: relative; }

.main_img img { height: 180px; width: 250px; overflow-x: hidden; overflow-y: hidden; position: relative; z-index: 1; transition-delay: 0s; transition-duration: 1s; transition-property: all; transition-timing-function: ease; }

.main_img .show { background: rgba(0, 0, 0, 0.4); height: 180px; left: 0; opacity: 0; filter: alpha(opacity=0); position: absolute; top: 0; transition-delay: 0s; transition-duration: 0.3s; transition-property: opacity; transition-timing-function: ease-in; width: 250px; z-index: 200; }

.main_img .show .imgArea { left: 50%; bottom: 0; margin: -15px 0px 0px -40px; opacity: 0; position: absolute; transition-delay: 0s; transition-duration: 0.4s; transition-property: all; transition-timing-function: ease; }

.main_img .show .imgArea a { color: rgba(255,255,255, 0.8); display: block; padding: 5px 12px; border: rgba(255,255,255, 0.6) 1px solid; border-radius: 8px; font-size: 16px; }

.main_img .show .imgArea a:hover { background: rgba(255,255,255, 0.7); color: rgba(0,0,0, 0.6); }

.main_img:hover .show { opacity: 1; filter: alpha(opacity=100); }

.main_img:hover .show .imgArea { opacity: 1; filter: alpha(opacity=100); bottom: 40%; }

.main_img:hover img { transform: scale(1.2, 1.2); }

html+css3鼠标移上图片放大遮罩

6、代码整体结构。

html+css3鼠标移上图片放大遮罩

7、查看效果。

html+css3鼠标移上图片放大遮罩

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢