css3鼠标悬停图片文字展示动画效果
css3鼠标悬停图片文字展示动画效果
html:
<div class="trade-content"> <div class="trade-title"> <p>企业行业专属建站</p> </div> <div class="trade-black"> <div class="trade-box"> <div class="trade-box-list"> <div class="trade-box-item item01"> <a href="#"> <div class="item-logo"> <img src="images/img001.svg" alt=""> </div> <div class="item-title">外贸行业</div> <div class="item-text"> <p>母语级翻译</p> <p>提供“海外部署”</p> <p>打通海外社交媒体</p> <p>海外商机汇集</p> </div> </a> </div> <div class="trade-box-item item02"> <a href="#"> <div class="item-logo"> <img src="images/img002.svg" alt=""> </div> <div class="item-title">培训行业</div> <div class="item-text"> <p>课程管理</p> <p>线上报名缴费</p> <p>约课\试听</p> <p>教师\学员管理</p> </div> </a> </div> <div class="trade-box-item item03"> <a href="#"> <div class="item-logo"> <img src="images/img003.svg" alt=""> </div> <div class="item-title">机械行业</div> <div class="item-text"> <p>产品多参数展示</p> <p>360°产品展示</p> <p>视频、下载</p> <p>参数对比、批量询价</p> </div> </a> </div> <div class="trade-box-item item04"> <a href="#"> <div class="item-logo"> <img src="images/img004.svg" alt=""> </div> <div class="item-title">家装行业</div> <div class="item-text"> <p>装修在线报价</p> <p>装修效果动态</p> <p>设计工具</p> <p>系统对接</p> </div> </a> </div> <div class="trade-box-item item05"> <a href="#"> <div class="item-logo"> <img src="images/img005.svg" alt=""> </div> <div class="item-title">酒店民宿业</div> <div class="item-text"> <p>在线订房订餐业务</p> <p>一键导航</p> <p>移动端营销</p> </div> </a> </div> </div> </div> </div> </div>
css:
创建main.css
html, body, div, dl, dt, dd, ol, ul, li, h1, h2, h3, h4, h5, h6, p, blockquote, pre, button, fieldset, form, input, legend, textarea, th, td{ margin: 0; padding: 0; } html,body{ margin: 0; color: #333; height: 100%; } *{ box-sizing: border-box; } a{ color: #666; text-decoration: none; } a:hover{ color: #eee; } img{ border: 0; } button{ outline: 0; } body{ background-color: #f4f5f9; color: #666; font-family: 'Microsoft Yahei',sans-serif; } button, input, optgroup, select, textarea{ margin: 0; outline: 0; font: inherit; color: inherit; } li{ list-style: none; } .clearfix::after{ clear: both; content: '.'; display: block; height: 0; visibility: hidden; } .trade-content{ padding: 30px 0; } .trade-title{ font-size: 24px; color: #333; text-align: center; margin: 50px 0; position: relative; } /* 绘制一个倒三角形 */ .trade-title::before{ content: ''; width: 0; height: 0; position: absolute; bottom: -19px; left: 50%; border: 6px solid; border-color: #20b09f transparent transparent; transform: translateX(-50%); } /* 绘制一个短横线 */ .trade-title::after{ content: ''; width: 52px; height: 3px; background-color: #20b09f; position: absolute; bottom: -8px; left: 50%; transform: translateX(-50%); } .trade-black{ height: 400px; background-color: #30383e; } /* .trade-box 让这个盒子水平居中 */ .trade-box{ width: 1200px; margin: 0 auto; position: relative; transition: all 0.3s ease; } /* .trade-box-list 将这个盒子转化成 弹性容器 */ .trade-box-list{ display: flex; flex-direction: row; justify-content: center; align-items: center; } /* 弹性项目 */ .trade-box-item{ height: 400px; text-align: center; flex: 1; position: relative; background-repeat: no-repeat; background-position: center center; background-size: 100% auto; } .trade-content .trade-box-item::before{ content: ''; width: 100%; height: 100%; position: absolute; left: 0; top: 0; background-color: rgba(0,0,0,0.6); transition: all 0.4s cubic-bezier(0.4,0,0.2,1); } .trade-box-item a{ width: 100%; height: 100%; position: absolute; left: 0; top: 0; } a,button,input,textarea{ transition: all 0.3s ease; } /* 将包裹图片的.item-logo 设置为 */ .item-logo{ margin: 0 auto; display: block; } .trade-content .trade-box-item .item-logo{ position: relative; margin-top: 120px; transition: all 0.4s cubic-bezier(0.4,0,0.2,1); } .item-logo img{ display: block; margin: 0 auto; max-width: 100%; } .item-title{ font-size: 20px; font-weight: bold; color: #fff; padding: 20px 0; position: relative; } .trade-content .item-text::before{ content: ''; display: block; width: 20px; border-bottom: 2px solid #fff; margin: 0 auto 20px; transition: all 0.4s cubic-bezier(0.4,0,0.2,1); } .item-text{ position: relative; opacity: 0; margin-top: 10px; transition: all 0.4s cubic-bezier(0.4,0,0.2,1); } .item-text p{ color: #fff; font-size: 16px; margin-bottom: 5px; } .trade-content .item01{ background-image: url('./../img/icon-at01.png'); } .trade-content .item02{ background-image: url('./../img/icon-at02.png'); } .trade-content .item03{ background-image: url('./../img/icon-at03.png'); } .trade-content .item04{ background-image: url('./../img/icon-at04.png'); } .trade-content .item05{ background-image: url('./../img/icon-at05.png'); } .trade-content .trade-box-item:hover .item-text{ display: block; opacity: 1; margin-top: 0; } .trade-content .trade-box-item:hover::before{ background-color: rgba(32,176,159,0.9); } .trade-content .trade-box-item:hover .item-logo{ margin-top: 80px; } .trade-content .trade-box-item:hover .item-title::before{ opacity: 0; margin-bottom: 0; }
还没有留言,还不快点抢沙发?