此前写的那个太复杂了,来点简单的核心
<html>
<head>
<title></title>
<style type="text/css">
* { margin: 0; padding: 0; border: none; }
.Bl {
width: 600px;
height: 540px;
margin: 0 auto;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.Bl > input {
width: 20%;
height: 40px;
position: absolute;
cursor: pointer;
opacity: 0;
}
.Bl input:nth-of-type(1){ left: 0%; }
.Bl input:nth-of-type(2){ left: 20%; }
.Bl input:nth-of-type(3){ left: 40%; }
.Bl input:nth-of-type(4){ left: 60%; }
.Bl input:nth-of-type(5){ left: 80%; }
/*切换效果*/
.Bl input:nth-of-type(1):checked ~ span:nth-of-type(1) { color: white; } /* ~ 选择兄弟元素 */
.Bl input:nth-of-type(2):checked ~ span:nth-of-type(2) { color: white; }
.Bl input:nth-of-type(3):checked ~ span:nth-of-type(3) { color: white; }
.Bl input:nth-of-type(4):checked ~ span:nth-of-type(4) { color: white; }
.Bl input:nth-of-type(5):checked ~ span:nth-of-type(5) { color: white; }
.Bl input:nth-of-type(1):checked ~ .pagebox > .pages { }
.Bl input:nth-of-type(2):checked ~ .pagebox > .pages { transform: translateY(-100%); }
.Bl input:nth-of-type(3):checked ~ .pagebox > .pages { transform: translateY(-200%); }
.Bl input:nth-of-type(4):checked ~ .pagebox > .pages { transform: translateY(-300%); }
.Bl input:nth-of-type(5):checked ~ .pagebox > .pages { transform: translateY(-400%); }
span {
display: block;
width: 20%;
height: 40px;
background-color: red;
float: left;
text-align: center;
line-height: 40px;
font-size: 20px;
}
.pagebox,.pages {
width: 100%;
height: 500px;
}
.pagebox {
overflow: hidden;
}
.pages {
transition: all 0.5s;
}
.page {
width: 100%;
height: 100%;
text-align: center;
font-family: "微软雅黑";
font-size: 30px;
line-height: 500px;
color: white;
}
.page1 { background-color: pink; }
.page2 { background-color: blue; }
.page3 { background-color: red; }
.page4 { background-color: green; }
.page5 { background-color: black; }
</style>
</head>
<body>
<div class="Bl">
<input type="radio" name="btn" checked ><span>1</span>
<input type="radio" name="btn" ><span>2</span>
<input type="radio" name="btn" ><span>3</span>
<input type="radio" name="btn" ><span>4</span>
<input type="radio" name="btn" ><span>5</span>
<section class="pagebox">
<div class="pages">
<div class="page page1">This is page1</div>
<div class="page page2">This is page2</div>
<div class="page page3">This is page3</div>
<div class="page page4">This is page4</div>
<div class="page page5">This is page5</div>
</div>
</section>
</div>
</body>
</html>
总结
以上所述是小编给大家介绍的纯CSS3制作页面切换效果的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
标签:
css,页面切换,css切换
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无争山庄资源网 Copyright www.whwtcm.com
暂无“纯CSS3制作页面切换效果的实例代码”评论...
更新日志
2025年10月27日
2025年10月27日
- 小骆驼-《草原狼2(蓝光CD)》[原抓WAV+CUE]
- 群星《欢迎来到我身边 电影原声专辑》[320K/MP3][105.02MB]
- 群星《欢迎来到我身边 电影原声专辑》[FLAC/分轨][480.9MB]
- 雷婷《梦里蓝天HQⅡ》 2023头版限量编号低速原抓[WAV+CUE][463M]
- 群星《2024好听新歌42》AI调整音效【WAV分轨】
- 王思雨-《思念陪着鸿雁飞》WAV
- 王思雨《喜马拉雅HQ》头版限量编号[WAV+CUE]
- 李健《无时无刻》[WAV+CUE][590M]
- 陈奕迅《酝酿》[WAV分轨][502M]
- 卓依婷《化蝶》2CD[WAV+CUE][1.1G]
- 群星《吉他王(黑胶CD)》[WAV+CUE]
- 齐秦《穿乐(穿越)》[WAV+CUE]
- 发烧珍品《数位CD音响测试-动向效果(九)》【WAV+CUE】
- 邝美云《邝美云精装歌集》[DSF][1.6G]
- 吕方《爱一回伤一回》[WAV+CUE][454M]
