css實現的輪播和點擊切換(無js版)

來源:互聯網
上載者:User

標籤:

.slide{        position: relative;        margin:auto;        width: 600px;        height: 200px;        text-align: center;        font-family: Arial;        color: #FFF;        overflow: hidden;    }    .slide ul{        margin:10px 0;        padding:0;        width: 9999px;        transition:all 0.5s;    }    /*//自動播放*/    .slide .slide-auto{                animation:marginLeft 10.5s infinite;    }    .slide li{        float: left;        width: 600px;        height: 200px;        list-style: none;        line-height: 200px;        font-size: 36px;    }    .slide li:nth-child(1){        background: #9fa8ef;    }    .slide li:nth-child(2){        background: #ef9fb1;    }    .slide li:nth-child(3){        background: #9fefc3;    }    .slide input[name="sildeInput"]{        display: none;    }    .slide label[for^="sildeInput"]{        position: absolute;        top:170px;        width: 20px;        height: 20px;        margin: 0 10px;        line-height: 20px;        color: #FFF;        background: #000;        cursor: pointer;    }    @keyframes marginLeft{        0%{margin-left: 0;}        28.5%{margin-left: 0;}        33.3%{margin-left: -600px;}        62%{margin-left: -600px;}        66.7%{margin-left: -1200px;}        95.2%{margin-left: -1200px;}        100%{margin-left: 0;}    }    .slide label[for="sildeInput1"]{        left: 0;    }    .slide label[for="sildeInput2"]{        left: 30px;    }    .slide label[for="sildeInput3"]{        left: 60px;    }    #sildeInput1:checked ~ ul{ margin-left: 0;}    #sildeInput2:checked ~ ul{ margin-left: -600px;}    #sildeInput3:checked ~ ul{ margin-left: -1200px;}

 

<!-- 自動播放 --><div class="slide">    <ul class="slide-auto">        <li>one</li>        <li>two</li>        <li>three</li>    </ul></div><!-- 點擊輪播 --><div class="slide">    <input type="radio" name="sildeInput" value="0" id="sildeInput1" checked hidden/>    <label for="sildeInput1">1</label>    <input type="radio" name="sildeInput" value="1" id="sildeInput2" hidden/>    <label for="sildeInput2">2</label>    <input type="radio" name="sildeInput" value="1" id="sildeInput3" hidden/>    <label for="sildeInput3">3</label>    <ul>        <li>one-點擊切換</li>        <li>two-點擊切換</li>        <li>three-點擊切換</li>    </ul></div>




 

  • one
  • two
  • three
1 2 3
  • one-點擊切換
  • two-點擊切換
  • three-點擊切換

css實現的輪播和點擊切換(無js版)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.