国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > CSS > 正文

純CSS3制作頁面切換效果的實例代碼

2024-07-11 09:00:02
字體:
來源:轉載
供稿:網友

此前寫的那個太復雜了,來點簡單的核心

<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制作頁面切換效果的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泸州市| 大埔县| 齐齐哈尔市| 招远市| 京山县| 镶黄旗| 诏安县| 黄平县| 湄潭县| 达拉特旗| 阳曲县| 怀化市| 赫章县| 和顺县| 兴文县| 县级市| 连云港市| 鹤峰县| 浏阳市| 建宁县| 黄浦区| 梨树县| 三原县| 永修县| 闽侯县| 方正县| 焉耆| 望奎县| 修武县| 会泽县| 阿拉尔市| 嘉鱼县| 永登县| 合江县| 宿松县| 梁河县| 都匀市| 鹤岗市| 聂荣县| 泰兴市| 临邑县|