css 产生huck,CSS3 悬停时出现图像标题

CSS

语言:

CSSSCSS

确定

@import "https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300|Pacifico";

*,

*:after,

*:before {

box-sizing: border-box;

}

.text--center {

text-align: center;

}

h1 {

font-size: 3em;

}

h2 {

font-size: 2em;

font-style: italic;

}

html {

display: flex;

align-items: center;

justify-content: center;

}

body {

height: 100%;

user-select: none;

font-family: 'Open Sans Condensed', sans-serif;

}

.wrapper {

width: 400px;

overflow: hidden;

margin: 0 auto;

box-shadow: 0 15px 50px rgba(0, 0, 0, 0.5);

}

.caption {

position: relative;

-webkit-backface-visibility: hidden;

}

.caption img {

max-width: 100%;

height: auto;

display: block;

transition: opacity .2s ease-in-out;

}

.caption img:hover {

opacity: .5;

}

.caption::after,

.caption::before {

position: absolute;

width: 100%;

height: 50%;

color: #fff;

z-index: 1;

transition: all 300ms ease;

}

.caption::before {

content: attr(data-title);

background: rgba(0, 0, 0, 0.5);

font-size: 4em;

font-family: 'Pacifico', sans-serif;

text-align: center;

padding-top: 13%;

transform: translateY(-100%) scale(0.8);

}

.caption::after {

content: attr(data-description) " ...";

background: rgba(204, 204, 204, 0.7);

top: 50%;

padding: 20px;

font-size: 1.4em;

transform: translateY(100%) scale(0.8);

color: #000;

}

.caption:hover::before,

.caption:hover::after {

transform: translateY(0%) scale(1);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值