純CSS3制作頁(yè)面切換效果的實(shí)例代碼
發(fā)布時(shí)間:2019-05-30 12:03:23 作者:佚名
我要評(píng)論

這篇文章主要介紹了純CSS3制作頁(yè)面切換效果的實(shí)例代碼,代碼簡(jiǎn)單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
此前寫的那個(gè)太復(fù)雜了,來(lái)點(diǎn)簡(jiǎn)單的核心
<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>
總結(jié)
以上所述是小編給大家介紹的純CSS3制作頁(yè)面切換效果的實(shí)例代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
如果你覺(jué)得本文對(duì)你有幫助,歡迎轉(zhuǎn)載,煩請(qǐng)注明出處,謝謝!
相關(guān)文章
怎樣實(shí)現(xiàn)H5+CSS3手指滑動(dòng)切換圖片的示例代碼
這篇文章主要介紹了怎樣實(shí)現(xiàn)H5+CSS3手指滑動(dòng)切換圖片的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小2019-05-05css實(shí)現(xiàn)導(dǎo)航切換的實(shí)例代碼
本文通過(guò)實(shí)例代碼給大家介紹了css實(shí)現(xiàn)導(dǎo)航切換效果,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2018-08-15用CSS實(shí)現(xiàn)Tab頁(yè)切換效果的示例代碼
這篇文章主要介紹了用CSS實(shí)現(xiàn)Tab頁(yè)切換效果的示例代碼的相關(guān)資料,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-03-19CSS實(shí)現(xiàn)Tab頁(yè)切換實(shí)例代碼
這篇文章主要介紹了CSS實(shí)現(xiàn)Tab頁(yè)切換實(shí)例代碼,需要的朋友可以參考下2018-01-31CSS使用classList實(shí)現(xiàn)兩個(gè)按鈕樣式的切換
在一些頁(yè)面我們需要使用兩個(gè)按鈕來(lái)回切換,怎么實(shí)現(xiàn)這樣的功能呢?下面小編給大家?guī)?lái)了CSS使用classList實(shí)現(xiàn)兩個(gè)按鈕樣式的切換效果,需要的朋友跟隨腳本之家小編一起學(xué)習(xí)2018-01-24