*新闻详情页*/>
本文详细介绍了CSS 照片动漫殊效的示例编码(相框),共享给大伙儿,实际以下:
下面是实际效果图
HTML编码
<!-- 主器皿 --> <div class="box"> <!-- 照片 --> <img src="images/pic.png" alt=""/> <!-- 內容 --> <div class="box-inner-content"> <h3 class="title">Rabbit</h3> <span class="post">Web Developer</span> </div> </div>
CSS编码
/* 原始化 */ body, html { font-size: 100%; } * { padding: 0; margin: 0; box-sizing: border-box; } body { background: #494A5F; font-weight: 500; font-size: 1.05em; font-family: "Microsoft YaHei","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif; } /* 外层器皿 */ .box { margin: 100px auto; width: 400px; height: 400px; overflow: hidden; position: relative; } .box:before { content: ""; display: block; border: 30px solid rgba(255, 255, 255, 0.3); position: absolute; top: 5px; left: 5px; bottom: 5px; right: 5px; opacity: 1; z-index: 2; transition: all 0.3s ease 0s; } .box:hover:before { top: 0; left: 0; right: 0; bottom: 0; border: 10px solid rgba(255, 255, 255, 0.18); } .box:after { content: ""; display: block; border: 8px solid #fff; position: absolute; top: 35px; left: 35px; bottom: 35px; right: 35px; opacity: 1; z-index: 1; transition: all 0.5s ease 0s; } .box:hover:after { top: 0; left: 0; bottom: 0; right: 0; opacity: 0; } /* 照片 */ .box img { width: 100%; height: auto; transform: scale(1.2); transition: all 0.5s ease 0s; } .box:hover img { transform: scale(1); } /* 文本內容 */ .box .box-inner-content { position: absolute; left: 45px; bottom: 125px; right: 45px; text-align: center; color: #fff; opacity: 0; transition: all 0.3s ease 0s; } .box:hover .box-inner-content { opacity: 1; bottom: 20px; text-shadow: 0 0 10px #000; } /* 题目 */ .box .title { font-size: 26px; font-weight: bold; margin: 0; } /* 文字 */ .box .post{ display: block; font-size: 16px; font-style: italic; margin-bottom: 10px; }
这里用了像素设置器皿的尺寸,假如用bootstrap等架构的话,能够设定成回应式。
由于照片设定成100%,因此会自融入外层器皿的尺寸。
必须留意的是外层器皿的position1定要设定成relative。
关键用到CSS3的transition特性,我这里没设访问器前缀,如今大多数数访问器都早已适配这个特性了。假如不安心又不嫌不便的话,最好是還是把各访问器前缀再加。
以上便是本文的所有內容,期待对大伙儿的学习培训有一定的协助,也期待大伙儿多多适用脚本制作之家。
Copyright © 2002-2020 小游戏源代码_互动小游戏微信_自制小游戏_html5游戏_制作游戏大概多少钱 版权所有 (网站地图) 粤ICP备10235580号