1.双开门
<div class="father">
<div class="left">
</div>
<div class="right">
</div>
</div>
*{
padding: 0;
margin: 0;
}
.father {
background-color: yellowgreen;
width: 100%;
height: 800px;
display: flex;
justify-content: space-between;
}
.left {
background-color: blue;
width: 50%;
height: 800px;
transition: width 0.3;
}
.right {
background-color: pink;
width: 50%;
height: 800px;
transition: width 0.3;
}
.father:hover .left {
transform: translate(-100%);
}
.father:hover .right {
transform: translateX(100%);
}
2.水平垂直居中
<div class="father">
<div class="son">
</div>
</div>
.father {
background-color: yellow;
width: 100px;
height: 100px;
position: relative;
}
.son {
position: absolute;
background-color: blue;
width: 20px;
height: 20px;
margin: 0 auto;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
3.旋转
<div class="box">
</div>
<img src="./luntai.jpg" class="img1" alt="">
<br>
<img src="./luntai.jpg" class="img2" alt="">
.box {
width: 100px;
height: 100px;
background-color: yellowgreen;
margin: 100px auto;
transition: all 5s;
}
.box:hover {
transform: rotateZ(60deg);
transform: rotate3d(1,1,0,180deg);
}
img{
width: 200px;
height: 200px;
transition: 10s;
}
img1:hover {
transform: translateX(800px) rotate(720deg);
}
.img2:hover {
transform: scale(0.4);
}
4.文字立方体切换
.father {
width: 100px;
height: 50px;
margin: 100px auto;
background-color: yellowgreen;
transform-style: preserve-3d;
transition: all 0.3s;
position: relative;
transform-style: preserve-3d;
}
.son1 {
position: absolute;
top: 0;
left: 0;
width: 100px;
height: 50px;
background-color: blue;
transform: translateZ(25px);
}
.son2 {
top: 0;
left: 0;
position: absolute;
width: 100px;
height: 50px;
background-color: red;
transform: translateY(-25px) rotateX(90deg);
}
.father:hover {
transform: rotateX(-90deg);
}
<body>
<div class="father">
<div class="son1">
</div>
<div class="son2">
</div>
</div>
</body>
5.缩放
.box1 {
width: 200px;
height: 200px;
background-color: yellowgreen;
margin: 100px auto;
overflow: hidden;
display: flex;
align-items: center;
}
img {
margin: 0px auto;
width: 80px;
height: 80px;
transition: all 3s;
opacity: 0;
transform: scale(10);
}
img:hover {
opacity: 1;
transform: scale(1);
}
<body>
<div class="box1">
<img src="../旋转/luntai.jpg" alt="">
</div>
</body>
5.视距 perspective 一般加给body perspective 视距值越大 微小的, 视距值越小 越猛烈
.div1 {
width: 100px;
height: 100px;
background-color: pink;
transition: all 0.3s;
margin: 0 auto;
}
body {
perspective: 1000px;
}
.div1:hover {
transform: translateZ(100px);
}
<div class="div1">
</div>
6.渐变
.div1 {
width: 100px;
height: 100px;
background-image: linear-gradient(90deg,transparent,red);
}
<div class="div1">
</div>
7.产品展示
width: 300px;
height: 212px;
margin: 100px auto;
background-color: yellow;
position: relative;
overflow: hidden;
}
img {
width: 300px;
height: 212px;
}
.mask {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-image: linear-gradient(
transparent,
rgba(0,0,0,0.5)
);
opacity: 0;
}
.box:hover .mask {
opacity: 1;
}
.box:hover img {
transform: scale(2);
}
.box:hover .info {
bottom: 0px;
}
.info {
position: absolute;
width: 100%;
bottom: -30px;
}
<div class="box">
<img src="转存失败,建议直接上传图片文件 https://img0.baidu.com/it/u=2513734713,4075989325&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt="转存失败,建议直接上传图片文件">
<div class="mask"></div>
<div class="info">
<p>职能体</p>
<h2>后付款发货反馈哈开发贷款撒谎,和范德萨好的</h2>
<a href="#">了解更多</a>
</div></div>
</div>
<div class="box">
<img src="https://img0.baidu.com/it/u=2513734713,4075989325&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt="" />
<div class="mask"></div>
<div class="info">
<p>职能体</p>
<h2>后付款发货反馈哈开发贷款撒谎,和范德萨好的</h2>
<a href="#">了解更多</a>
</div>
</div>
8. 3d立方体
.body {
perspective: 600px;
}
.father {
position: relative;
width: 100px;
height: 100px;
background-color: transparent;
border: 1px solid #000;
transform-style: preserve-3d;
margin: 100px auto;
}
.son1{
position: absolute;
width: 100px;
height: 100px;
background-color: pink;
transform: translateZ(100px);
}
.son2 {
position: absolute;
width: 100px;
height: 100px;
background-color: red;
transform: translateZ(-100px);
}
.father:hover {
transform: rotateY(60deg);
}
<div class="father">
<div class="son1">
A
</div>
<div class="son2">
B
</div>
</div>