码迷,mamicode.com
首页 > 其他好文 > 详细

导航栏制作

时间:2019-07-21 10:48:07      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:使用   20px   img   char   har   lang   idt   set   center   

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>导航栏</title>
    <style>
    .nav{
        text-align: center;
        }
        .nav a{
        width: 120px;
        height: 50px;
        display: inline-block;
        background-image: url(images/bg1.png);
        text-align: center;
        color: #fff;
        line-height: 50px;
        text-decoration: none;

    }

    .nav a:hover{
        background-image: url(images/bg2.png);
    }    

    </style>
</head>
<body>
     <div class="nav">
         <a href="#">网站导航</a>
         <a href="#">网站导航</a>
         <a href="#">网站导航</a>
         <a href="#">网站导航</a>
         <a href="#">网站导航</a>
         <a href="#">网站导航</a>

     </div>



</body>
</html>

实现效果如下:

技术图片

注意点:

1.background image :url(),相对路径,文件夹名称最好用英文。

2.选择器的使用;

3.文本居中对齐,text-align

4.行内元素 display:inline-block

 

 

导航栏制作

标签:使用   20px   img   char   har   lang   idt   set   center   

原文地址:https://www.cnblogs.com/fhtax/p/11220243.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!