实现开门效果

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
width: 1366px;
height: 600px;
background: url(images/bg.jpg);
margin: 0 auto;
position: relative;
overflow: hidden;
}
.box::after,
.box::before {
content: '';
float: left;
width: 50%;
height: 600px;
background: url(images/fm.jpg);
transition: all .5s;
}
.box::after {
background-position: right 0;
}
.box:hover::before {
transform: translate(-100%);
}
.box:hover::after {
transform: translate(100%);
}
</style>
</head>
<body>
<div class="box">
</div>
</body>
</html>
通过display:inline-block实现的话,要注意间隙问题
.box::after,
.box::before {
content: '';
display: inline-block;
width: 50%;
height: 600px;
background: url(images/fm.jpg);
transition: all .5s;
}


实现新闻效果
图片移入放大
遮罩
字体图标运用

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="./iconfont/iconfont.css">
</head>
<body>
<div class="box">
<ul>
<li>
<a href="#">
<div class="bg">
<img src="images/huawei1.jpeg" alt="">
</div>
<div class="txt">
<h4>产品</h4>
<h5>OceanStor Pacific 海量存储斩获2021 Interop金奖</h5>
<p>
<span>了解更多</span>
<i class="iconfont icon-arrow-right"></i>
</p>
</div>
</a>
<div class="mask"></div>
</li>
<li>
<a href="#">
<div class="bg">
<img src="images/huawei2.jpeg" alt="">
</div>
<div class="txt">
<h4>产品</h4>
<h5>OceanStor Pacific 海量存储斩获2021 Interop金奖</h5>
<p>
<span>了解更多</span>
<i class="iconfont icon-arrow-right"></i>
</p>
</div>
</a>
<div class="mask"></div>
</li>
<li>
<a href="#">
<div class="bg">
<img src="images/product.jpeg" alt="">
</div>
<div class="txt">
<h4>产品</h4>
<h5>OceanStor Pacific 海量存储斩获2021 Interop金奖</h5>
<p>
<span>了解更多</span>
<i class="iconfont icon-arrow-right"></i>
</p>
</div>
</a>
<div class="mask"></div>
</li>
</ul>
</div>
</body>
</html>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
li {
list-style: none;
}
a {
text-decoration: none;
}
.box ul li:first-child {
background-color: red;
}
img {
width: 100%;
vertical-align: middle;
}
.box {
width: 1110px;
height: 247px;
margin: 20px auto;
}
.box .bg {
float: left;
width: 450px;
margin-right: 30px;
overflow: hidden;
}
.box li {
position: relative;
float: left;
width: 350px;
height: 247px;
margin-right: 30px;
overflow: hidden;
}
.box li:last-child {
margin-right: 0;
}
.box li .bg img {
transition: all .5s;
}
.box li:hover .bg img {
transform: scale(1.2);
}
.mask {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-image: linear-gradient(transparent,
rgba(0, 0, 0, .6));
opacity: 0;
transition: all .5s;
}
.box li:hover .mask {
opacity: 1;
}
.box .txt {
position: absolute;
left: 0;
bottom: -50px;
width: 350px;
height: auto;
padding: 20px 30px;
z-index: 1;
color: #fff;
transition: transform .5s;
}
.box .txt h4 {
font-size: 14px;
font-weight: 400;
line-height: 2em;
color: #fff;
}
.box .txt h5 {
margin-bottom: 40px;
font-size: 18px;
line-height: 1.5em;
color: #fff;
}
.box .txt p {
color: #fff;
font-size: 14px;
}
.box .txt p .iconfont {
color: #c7000b;
vertical-align: middle;
font-size: 20px;
font-weight: 700;
}
.box li:hover .txt {
transform: translateY(-50px);
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!