zoukankan      html  css  js  c++  java
  • navbar导航栏

    效果

    1.HTML:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link type="text/css" rel="stylesheet" href="css/style.css">
    </head>
    <body>
        <div id="header">
            <div class="navbar">
                <img class="navbar-left" src="assets/images/navbar_logo.png">
                <ul class="narbar-right">
                    <li>
                        <a class="active" href="">Home</a>
                    </li>
                    <li>
                        <a class="" href="">product</a>
                    </li>
                    <li>
                        <a class="" href="">About</a>
                    </li>
                    <li>
                        <a class="" href="">JoinUs</a>
                    </li>
                    <li>
                        <a class="" href="">Contact</a>
                    </li>
                </ul>
            </div>
        </div>
    </body>
    </html>

    2.CSS

    body{
        background-color: #f9f9f9;
        margin: 0;
        padding: 0;
    }
    
    #header{
        background-color: #ffffff;
        width: 100%;
        height: 52px;
        border-bottom: 1px solid #e9e9e9;
        position: fixed;
        top: 0;
        left: 0;
    }
    
    .navbar{
        margin: 4px 20px;
        display: block;
    }
    
    .navbar-left{
        float: left;
        width: 44px;
    }
    
    .narbar-right{
        float: right;
    }
    
    .navbar li{
        list-style-type: none;
        margin-left: 20px;
        display: inline-block;
    }
    
    .navbar li .active{
        color: #ff7d0a;
    }
    
    .navbar a{
        font-size: 16px;
        font-weight: 800;
        color: #636363;
        text-decoration: none;
    }
    
    .navbar a:hover{
        color: #ee7204;
    }

     

    导航栏修改

    1.HTML

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link type="text/css" rel="stylesheet" href="css/navbar.style.css">
    </head>
    <body>
        <div id="header">
            <div class="layout">
                <ul class="nav">
                    <li><a class="icon icon-home" href="#">Home</a> </li>
                    <li><a class="icon icon-hot" href="#">Hot</a> </li>
                    <li><a class="icon icon-find" href="#">Find</a> </li>
                    <li><a class="icon icon-game" href="#">Game</a> </li>
                    <li><a class="active" href="#">About</a> </li>
                    <li><a href="#">Contact</a> </li>
                </ul>
            </div>
        </div>
    </body>
    </html>

    2.CSS

    *{
        margin: 0;
        padding: 0;
    }
    
    ul{
        list-style: none;
    }
    
    ul li{
        display: inline-block;
    }
    
    li a{
        text-decoration: none;
        color: #3b3b3b;
        font-size: 16px;
        font-weight: 500;
    }
    
    .layout{
        width: 900px;
        margin: 0 auto;
    }
    
    #header{
        margin-top: 20px;
    }
    
    #header .nav{
        border-top: 2px solid rgba(227, 19, 220, 0.95);
        border-bottom: 1px solid rgba(227, 19, 220, 0.95);
        padding: 15px;
    }
    
    #header .nav li{
        width: 120px;
        height: 20px;
        line-height: 20px;
        text-align: center;
        background-image: url("../assets/images/nav_cutline.png");
        background-repeat: no-repeat;
    }
    
    #header .nav li a{
        padding: 4px 20px;
        display: inline-block;
    }
    
    #header .nav li:first-of-type{
        margin-left: 60px;
    }
    
    #header .nav li:last-of-type{
        /*background-position: right;*/
    }
    
    #header .nav .active{
        color: #ffffff;
        padding: 2px 15px;
        border-radius: 20px;
        display: inline-block;
        background-color: #e313dc;
    }
    
    #header .nav .icon{
        padding-left:40px;
        background-position: 15px 2px;
        background-repeat: no-repeat;
        background-size: 20px 20px;
    }
    
    #header .nav .icon-home{
        background-image: url("../assets/images/nav_home.png");
    }
    
    #header .nav .icon-hot{
        background-image: url("../assets/images/nav_hot.png");
    }
    
    #header .nav .icon-find{
        background-image: url("../assets/images/nav_find.png");
    }
    
    #header .nav .icon-game{
        background-image: url("../assets/images/nav_game.png");
    }

    每个<a>标签前面加入小的背景图片元素

  • 相关阅读:
    Hibernate实体对象三种状态
    tar命令: 对某目录文件打tar包时,排除指定的目录或文件
    开发项目时,提示 找不到类的解决方法,以及如何设置编译源目录
    当html中存在url中如: onclick="toView('参数1')", 参数1是特别字符,如&asop;&quot;' "等时,浏览器解析时会报错。解决方法如文中描述
    oracle表分区心得
    启动系统相关服务笔记整理
    使用PSD设计网页页面
    JAR、WAR、EAR 区别
    设置 MyEclipse 默认打开文件方式
    前端性能优化
  • 原文地址:https://www.cnblogs.com/xinjiebi/p/5065186.html
Copyright © 2011-2022 走看看