html5怎么写轮播图(旋转轮播图效果的实现)
html5怎么写轮播图(旋转轮播图效果的实现)美图分享-暗精灵<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <style> body { /* 指定观察者与「z=0」平面的距离,使具有三维位置变换的元素产生透视效果 */ perspective: 1000px; } section { width: 300px; height: 200px; margin: 100px auto; background: url(images/暗精灵.jpg) no-repeat; background-size: cover; position:
自动旋转轮播图,无限循环1、实现效果图
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
body {
/* 指定观察者与「z=0」平面的距离,使具有三维位置变换的元素产生透视效果 */
perspective: 1000px;
}
section {
width: 300px;
height: 200px;
margin: 100px auto;
background: url(images/暗精灵.jpg) no-repeat;
background-size: cover;
position: relative;
/* 让父盒子里面的子盒子以3d效果显示 */
transform-style: preserve-3d;
animation: love 9s linear infinite;
}
@keyframes love {
0%{
transform: rotateY(0deg);
}
100%{
transform: rotateY(360deg);
}
}
section div {
width: 100%;
height: 100%;
background: url(images/暗精灵-北境战灵.jpg) no-repeat;
background-size: cover;
position: absolute;
top: 0;
left: 0;
}
section div:nth-child(1) {
transform: rotateY(0deg) translateZ(400px);
}
section div:nth-child(2) {
transform: rotateY(60deg) translateZ(400px);
}
section div:nth-child(3) {
transform: rotateY(120deg) translateZ(400px);
}
section div:nth-child(4) {
transform: rotateY(180deg) translateZ(400px);
}
section div:nth-child(5) {
transform: rotateY(240deg) translateZ(400px);
}
section div:nth-child(6) {
transform: rotateY(300deg) translateZ(400px);
}
</style>
</head>
<body>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
</body>
</html>
2、视频效果:
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
body {
/* 指定观察者与「z=0」平面的距离,使具有三维位置变换的元素产生透视效果 */
perspective: 1000px;
}
section {
width: 300px;
height: 200px;
margin: 100px auto;
background: url(images/暗精灵.jpg) no-repeat;
background-size: cover;
position: relative;
/* 让父盒子里面的子盒子以3d效果显示 */
transform-style: preserve-3d;
/* 设置动画 */
animation: love 9s linear infinite;
}
/* 规定动画 */
@keyframes love {
0%{
transform: rotateY(0deg);
}
100%{
transform: rotateY(360deg);
}
}
section div {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
}
section #div1 {
background: url(images/暗精灵-北境战灵.jpg) no-repeat;
background-size: cover;
}
section #div2 {
background: url(images/暗精灵-矩阵特工.jpg) no-repeat;
background-size: cover;
}
section #div3 {
background: url(images/暗精灵-胧月夜灵.jpg) no-repeat;
background-size: cover;
}
section #div4 {
background: url(images/暗精灵-绿森幻灵.jpg) no-repeat;
background-size: cover;
}
section #div5 {
background: url(images/暗精灵-青耕送喜.jpg) no-repeat;
background-size: cover;
}
section #div6 {
background: url(images/暗精灵-月也紫影.jpg) no-repeat;
background-size: cover;
}
section div:nth-child(1) {
transform: rotateY(0deg) translateZ(400px);
}
section div:nth-child(2) {
transform: rotateY(60deg) translateZ(400px);
}
section div:nth-child(3) {
transform: rotateY(120deg) translateZ(400px);
}
section div:nth-child(4) {
transform: rotateY(180deg) translateZ(400px);
}
section div:nth-child(5) {
transform: rotateY(240deg) translateZ(400px);
}
section div:nth-child(6) {
transform: rotateY(300deg) translateZ(400px);
}
</style>
</head>
<body>
<section>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<div id="div4"></div>
<div id="div5"></div>
<div id="div6"></div>
</section>
</body>
</html>
鼠标控制旋转轮播图
3、实现效果图
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<style>
body {
/* 指定观察者与「z=0」平面的距离,使具有三维位置变换的元素产生透视效果 */
perspective: 1000px;
}
section {
width: 300px;
height: 200px;
margin: 100px auto;
background: url(images/暗精灵.jpg) no-repeat;
background-size: cover;
position: relative;
/* 让父盒子里面的子盒子以3d效果显示 */
transform-style: preserve-3d;
/* 匀速 all 是可以省略的, 省略默认的all*/
transition: 5s linear;
}
/* 设置元素在其鼠标悬停时的样式。 */
section:hover {
/* 指定对象在y轴上的旋转角度 */
transform: rotateY(360deg);
}
section div {
width: 100%;
height: 100%;
background: url(images/暗精灵-北境战灵.jpg) no-repeat;
background-size: cover;
position: absolute;
top: 0;
left: 0;
}
section div:nth-child(1) {
transform: rotateY(0deg) translateZ(400px);
}
section div:nth-child(2) {
transform: rotateY(60deg) translateZ(400px);
}
section div:nth-child(3) {
transform: rotateY(120deg) translateZ(400px);
}
section div:nth-child(4) {
transform: rotateY(180deg) translateZ(400px);
}
section div:nth-child(5) {
transform: rotateY(240deg) translateZ(400px);
}
section div:nth-child(6) {
transform: rotateY(300deg) translateZ(400px);
}
</style>
</head>
<body>
<section>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
</body>
</html>
素材图片:
美图分享-暗精灵