温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用CSS3怎么实现一个页面切换效果

发布时间:2021-05-08 17:45:09 阅读:302 作者:Leah 栏目:web开发
前端开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

今天就跟大家聊聊有关使用CSS3怎么实现一个页面切换效果,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

<html>
<head>
    <title></title>
    <style type="text/css">
        * { margin0padding0border: none; } 
        .Bl {
            width600px; 
            height540px; 
            margin0 auto;
            position: relative;
            top50%;
            transformtranslateY(-50%);
        }
        .Bl > input {
            width20%;
            height40px;
            position: absolute;
            cursor: pointer;
            opacity0;
        }
        .Bl input:nth-of-type(1){ left0%; }
        .Bl input:nth-of-type(2){ left20%; }
        .Bl input:nth-of-type(3){ left40%; }
        .Bl input:nth-of-type(4){ left60%; }
        .Bl input:nth-of-type(5){ left80%; }
        /*切换效果*/
        .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 { transformtranslateY(-100%); }
        .Bl input:nth-of-type(3):checked ~ .pagebox > .pages { transformtranslateY(-200%); }
        .Bl input:nth-of-type(4):checked ~ .pagebox > .pages { transformtranslateY(-300%); }
        .Bl input:nth-of-type(5):checked ~ .pagebox > .pages { transformtranslateY(-400%); }
        span { 
            display: block;
            width20%;
            height40px; 
            background-color: red;
            float: left;
            text-align: center;
            line-height40px;
            font-size20px;
        }
        .pagebox,.pages {
            width100%; 
            height500px;
        }
        .pagebox {
            overflow: hidden;
        }
        .pages {
            transition: all 0.5s;
        }
        .page {
            width100%;
            height100%;
            text-align: center;
            font-family"微软雅黑";
            font-size30px;
            line-height500px;
            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怎么实现一个页面切换效果有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注亿速云行业资讯频道,感谢大家的支持。

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

原文链接:https://www.jb51.net/css/675692.html

AI

开发者交流群×