尘叶心繁

css3样式学习代码

电脑版发表于:2019/4/12 1:17

上代码!上代码!不说了

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="mystyle.css">
</head>
<body>
<div class="content">
<div></div>
<div></div>
<div></div>
<div><p>Hello!I hope you like it!</p><p>Thank you very much!</p></div>
</div>
</body>
</html>

css:

body{
margin: 0;
padding: 0;
/* 基本上扑满 */
height: 100vh;
width: 100%;
/* 
        盒子模型
        上下左右居中
    */
display: flex;
align-items: center;
justify-content: center;
}
.content{
/*
    相对定位 
     */
position: relative;
height: 640px;
width: 360px;
margin-top: 150px;
/* 通过颜色透明 */
background-color: rgba(0,0,0,.2);
transition: 0.5s;
/* 2D旋转 3D旋转 大小为自身的0.8  .8 == 0.8 */
transform: rotate(-30deg) skew(25deg) scale(.8);
}
.content div{
background-color: black;
/*
    相对于父级的相对定位 进行绝对定位 
     */
position: absolute;
width: 100%;
height: 100%;
color: white;
/* 左右居中 */
/* text-align: center; */
/* 上下居中 */
/* line-height: 640px; */
/* 过滤动画 */
transition: 1s;
}
p{
display: inline-block;
width: 100%;
font-size: 16px;
transform: translate(50px,50px);
}
.content:hover div:nth-child(4){
/* 基于上一次相对定位作出改变 */
transform: translate(160px,-160px);
/* 加粗 */
font-weight: bold;
/* 透明度 */
opacity: 1;
/* 投影方式 X轴偏移量 Y轴偏移量 阴影模糊半径 阴影扩展半径 阴影颜色;  */
box-shadow: -10px 10px 20px 5px red;
}
.content:hover div:nth-child(3){
transform: translate(120px,-120px);
opacity: 0.8;
}
.content:hover div:nth-child(2){
transform: translate(80px,-80px);
opacity: 0.6;
}
.content:hover div:nth-child(1){
transform: translate(40px,-40px);
opacity: 0.4;
}

用其工,迂回其力!

关于TNBLOG
TNBLOG,技术分享。技术交流:群号677373950
ICP备案 :渝ICP备18016597号-1
App store Android
精彩评论
{{item.replyName}}
{{item.content}}
{{item.time}}
{{subpj.replyName}}
@{{subpj.beReplyName}}{{subpj.content}}
{{subpj.time}}
猜你喜欢