代碼
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>css絲帶導(dǎo)航</title> <style type="text/css"> body,div,ul,li{margin:0;padding:0;font-family: '微軟雅黑';} /* 樣式重置 */ body {background-color:#444;} .nav{ width:450px; height:50px; background-color:#fff; margin:200px auto 0; position:relative; } .nav .left{ position:absolute; left:-18px; top:8px; width:36px; height:36px; background-color:#444; transform:rotate(45deg); /* 旋轉(zhuǎn)45度 */ } .nav .right{ position:absolute; right:-18px; top:8px; width:36px; height:36px; background-color:#444; transform:rotate(45deg); /* 旋轉(zhuǎn)45度 */ } .nav ul{ position:relative; top:-10px; width:350px; height:60px; margin:0 auto; overflow:hidden; display:flex; } .nav ul li { position:relative; top:10px; width:70px; height:50px; line-height:50px; text-align:center; background-color:#fff; transition: .4s; list-style: none; box-shadow:0 20px 0 -10px #444; cursor:pointer; } .nav ul li:hover { top:0; background-color:yellow; border-radius:3%; } .nav ul li:before { position:absolute; top:50px; display:block; content: ''; width:10px; height:10px; background-image:linear-gradient(45deg,#fff 50%,#ccc 50%); } .nav ul li:after { position:absolute; top:50px; right:0; display:block; content: ''; width:10px; height:10px; background-image:linear-gradient(-45deg,#fff 50%,#ccc 50%); } </style> </head> <body> <div class="nav"> <div class="left"></div> <ul> <li>HOME</li> <li>HOME</li> <li>HOME</li> <li>HOME</li> <li>HOME</li> </ul> <div class="right"></div> </div> </body> </html>
點(diǎn)擊 "運(yùn)行實(shí)例" 按鈕查看在線實(shí)例
今天在網(wǎng)上看到的一個(gè)這樣的導(dǎo)航,覺得挺好看的,就自己寫了下來(lái)
相對(duì)定位與絕對(duì)定位,包括偽類的使用,重在理解過(guò)程
微信掃碼
關(guān)注PHP中文網(wǎng)服務(wù)號(hào)
QQ掃碼
加入技術(shù)交流群
Copyright 2014-2025 http://ipnx.cn/ All Rights Reserved | php.cn | 湘ICP備2023035733號(hào)