100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > html点击小图轮播图 使用纯CSS实现点击轮播图效果 无js。

html点击小图轮播图 使用纯CSS实现点击轮播图效果 无js。

时间:2024-04-02 05:31:03

相关推荐

html点击小图轮播图 使用纯CSS实现点击轮播图效果 无js。

使用纯CSS实现图片轮播效果

首先我们来看一下所实现轮播图的最终效果:

轮播图 效果

接下来为html+css代码部分:

以下为HTML代码部分:

以下为CSS代码部分:

*{

margin:0;

padding:0;

}

.banner{

position:relative;

width:300px;

height:300px;

margin:50px auto;

border:5px solid lightcoral;

overflow:hidden;

}

.banner ul{

width:900px;

padding:0;

transition:all 1s;

}

.banner li{

list-style:none;

width:300px;

height:300px;

float:left;

}

.circle{

position:absolute;

bottom:10px;

left:92px;

}

.circle label{

display:inline-block;

width:20px;

height:20px;

border-radius:50%;

background:lightcoral;

margin:0 10px;

position:relative;

cursor:pointer;

}

.circle label::after{

content:'';

width:30px;

height:30px;

background:lightsalmon;

border-radius:50%;

position:absolute;

top:-5px;

left:-5px;

opacity:0;

}

#put1:checked~.circle label:first-of-type::after,

#put2:checked~.circle label:nth-of-type(2)::after,

#put3:checked~.circle label:nth-of-type(3)::after{

opacity:1;

}

#put1:checked~ul{

margin-left:0;

}

#put2:checked~ul{

margin-left:-300px;

}

#put3:checked~ul{

margin-left:-600px;

}

.left_arrow label{

display:inline-block;

width:24px;

height:44px;

top:50%;

left:0%;

margin-top:-22px;

position: absolute;

}

/* 圆点的put1,put2,put3和箭头的put1,put2,put3是相互联系的,同时受input制约 */

#put1:checked~.left_arrow label:nth-of-type(3),

#put2:checked~.left_arrow label:nth-of-type(1),

#put3:checked~.left_arrow label:nth-of-type(2){

margin-left:20px;

cursor:pointer;

background:url(../img/ban_prev.png) no-repeat center center;

}

.right_arrow label{

display:inline-block;

width:24px;

height:44px;

top:50%;

right:0%;

margin-top:-22px;

position: absolute;

}

#put1:checked~.right_arrow label:nth-of-type(2),

#put2:checked~.right_arrow label:nth-of-type(3),

#put3:checked~.right_arrow label:nth-of-type(1){

margin-right:20px;

cursor:pointer;

background:url(../img/ban_next.png) no-repeat center center;

}

以下为我所使用的图片素材文件,有需要可自取(均为png格式):

箭头图片素材1(透明)

箭头图片素材2(透明)

first.png

second.png

third.png

keep learning

转载请注明来源

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。