<div class="grid"> <figure class="effect-milo"> <img src="img/3.jpg"/> <figcaption> <h2>Faithful <span>Milo</span></h2> <p>Milo went to the woods. He took a fun ride and never came back.</p> </figcaption> </figure> </div>
.effect-milo{ overflow: hidden; backface-visibility: hidden; float: left; margin: 0; width: 480px; height: 360px; margin-right: 55px; position: relative; cursor: pointer; background: #2e5d5a; } .effect-milo img{ /*width: 100%;*/ height: 100%; width: calc(100% + 30px); transform: translate3d(-30px,0,0); -webkit-transform: translate3d(-30px,0,0); -webkit-transition: opacity 0.35s, -webkit-transform 0.35s; transition: opacity 0.35s,transform 0.35s; backface-visibility: hidden; } .effect-milo figcaption{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; text-align: center; } .effect-milo figcaption h2{ position: absolute; top: 74%; left: 20%; width: 100%; height: 100%; font-size: 30px; font-weight: 400; text-transform: uppercase; } .effect-milo figcaption span{ font-weight: 600; } .effect-milo figcaption p{ position: absolute; top: 10%; left: 10%; width: 40%; text-align: right; border-right: 1px solid #fff; padding-right: 10px; transform: translate3d(-30px,0,0); -webkit-transform: translate3d(-30px,0,0); transition: opacity 0.35s,transform 0.35s; -webkit-transition: opacity 0.35s,transform 0.35s; opacity: 0; } .effect-milo:hover img { transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); opacity: .6; } .effect-milo:hover p{ transform: translate3d(0,0,0); -webkit-transform: translate3d(0,0,0); opacity: 1; }
效果图
原图
鼠标悬浮效果
<div class="grid"> <figure class="effect-chico"> <img src="img/15.jpg"/> <figcaption> <h2>Silly <span>Chico</span></h2> <p>Chico's main fear was missing the morning bus.</p> </figcaption> </figure> </div>
.effect-chico{ overflow: hidden; backface-visibility: hidden; float: left; margin: 0; width: 480px; height: 360px; margin-right: 55px; position: relative; cursor: pointer; background: #3085a3; } .effect-chico img{ width: 100%; height: 100%; -webkit-transition: opacity 0.35s, -webkit-transform 0.35s; transition: opacity 0.35s, transform 0.35s; -webkit-transform: scale(1.12); transform: scale(1.12); } .effect-chico figcaption{ position: absolute; top: 0; left: 0; width: 100%; height: 100%; text-align: center; } .effect-chico figcaption h2{ position: absolute; top: 23%; left: 0; width: 100%; height: 100%; font-size: 30px; font-weight: 400; text-transform: uppercase; } .effect-chico figcaption span{ font-weight: 600; } .effect-chico figcaption p{ position: absolute; top: 39%; left: 25%; width: 50%; opacity: 0; -webkit-transition: opacity 0.35s, -webkit-transform 0.35s; transition: opacity 0.35s,transform 0.35s; -webkit-transform: scale(1.5); transform: scale(1.5); } .effect-chico figcaption:after{ content: ''; position:absolute; top: 30px; bottom: 30px; left: 30px; right: 30px; border:1px solid #fff; opacity: 0; -webkit-transition: opacity 0.35s, -webkit-transform 0.35s; transition: opacity 0.35s,transform 0.35s; -webkit-transform: scale(1.1); transform: scale(1.1); } .effect-chico:hover img{ opacity: .7; -webkit-transform: scale(1); transform: scale(1); } .effect-chico:hover p, .effect-chico:hover figcaption:after{ opacity: 1; -webkit-transform: scale(1); transform: scale(1); }
原图
鼠标悬浮效果图