網易雲音樂首頁導航樣式的實現


實現效果圖:

背景圖片:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{margin:0;padding:0;list-style-type:none;color: azure;text-decoration: none;}

        ul,ul li,ul li a {
            background: url("img/sprite.gif") no-repeat scroll left top;
        }
        ul {
            width: 100%;
            height: 40px;
            line-height: 40px;
            background-color:#CC0000;
            background-repeat: repeat-x;
            background-position: 0 0;
        }
        ul li {
            position: relative;
            float: left;
            padding:0  20px;
            background-position:0 -40px ;
}
</style> </head> <body> <ul> <li><a href="#" >首頁</a></li> <li><a href="#">素材</a></li> <li><a href="#" >圖片</a> </li> <li> <a href="#" >圖標</a> </li> </ul> </body> </html>

注意:background:url("img/sprite.gif") no-repeat scroll left top中的left后面的值不可缺少,可以為top、0、-9999px、999px等;
     background-repeat:repeat-x;放在ul或者li均可; 
     如果想讓背景邊框線呈現如圖效果 ,可在ul的樣式中加入padding-top:10px替代line-height:40px,
     並把ul,ul li,ul li a 此處的ul去掉;
 
     背景圖片的尺寸要符合實際導航欄的大小。
 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM