css3写一个简单的轮播图

直接上代码,拿去就能用,换图片直接改


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#frame {
position: absolute;
width: 300px;
height: 200px;
overflow: hidden;
border-radius: 5px
}

#dis {
position: absolute;
left: -50px;
top: -10px;
opacity: .5
}

#dis li {
display: inline-block;
width: 200px;
height: 20px;
margin: 0 50px;
float: left;
text-align: center;
color: #fff;
border-radius: 10px;
background: #000
}

#photos img {
float: left;
width: 300px;
height: 200px
}

#photos {
position: absolute;
z-index: 9;
width: calc(300px * 4); /*---修改图片数量的话需要修改下面的动画参数*/
}

.play {
animation: ma 10s infinite;
}

@keyframes ma {
0%, 25% {
margin-left: 0px;
}
30%, 50% {
margin-left: -300px;
}
55%, 75% {
margin-left: -600px;
}
80%, 100% {
margin-left: -900px;
}

}
</style>
</head>
<body>
<div id="frame">
<div id="photos" class="play">
<img src="img/1.jpg">
<img src="img/2.jpg">
<img src="img/3.jpg">
<img src="img/4.jpg">
<ul id="dis">
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
</div>
</div>
</body>
</html>

转载于:https://www.cnblogs.com/oldZhangFeng/p/7273285.html

好的,以下是一个简单的 HTML 和 CSS 3D 轮播图片示例,其中包含四张图片 : ```html <!DOCTYPE html> <html> <head> <title>3D轮播图片</title> <style> body { margin: 0; padding: 0; overflow: hidden; } .container { position: relative; width: 100vw; height: 100vh; perspective: 1000px; transform-style: preserve-3d; } .item { position: absolute; top: 0; left: 0; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; font-size: 5em; color: #fff; background-color: #333; transform-style: preserve-3d; transition: transform 1s; } .item:nth-child(1) { transform: rotateY(0deg) translateZ(500px); } .item:nth-child(2) { transform: rotateY(90deg) translateZ(500px); } .item:nth-child(3) { transform: rotateY(180deg) translateZ(500px); } .item:nth-child(4) { transform: rotateY(270deg) translateZ(500px); } .container:hover .item:nth-child(1) { transform: rotateY(-90deg) translateZ(500px); } .container:hover .item:nth-child(2) { transform: rotateY(0deg) translateZ(500px); } .container:hover .item:nth-child(3) { transform: rotateY(90deg) translateZ(500px); } .container:hover .item:nth-child(4) { transform: rotateY(180deg) translateZ(500px); } </style> </head> <body> <div class="container"> <div class="item">1</div> <div class="item">2</div> <div class="item">3</div> <div class="item">4</div> </div> </body> </html> ``` 在这个示例中,我们使用了 CSS 的 3D 变换来实现轮播图片的效果。每个图片元素都有不同的旋转角度和 3D 位移量。鼠标悬停在容器上时,通过修改旋转角度来实现图片的切换效果。 您可以将每个图片元素的内容替换成自己的图片链接或其他内容。如果您需要添加更多的图片,可以复制 `.item` 元素并根据需要修改旋转角度和位移量。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值