前端导航栏html5+css3

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        body{
            background: url("images/bg_title.jpg")  repeat-x,url("images/bg.jpg");
        }
        #logo{
            width:895px;
            height:45px;
            /*margin:上下 左右*/
            margin:50px auto;
            border-radius:10px;
            /*html + css3 渐变画图 */
            background-image:-webkit-linear-gradient(rgba(41,41,41,0.75) 0% ,rgba(54,54,54,0.72) 50%,rgba(24,23,23,0.94) 51%);
            box-shadow:1px 1px 33px #FFFFFF;/*设计阴影的*/
        }
        #logo ul li{
            width:127px;
            height:45px;
            list-style-type: none;/*去掉圆点*/
            float: left;/*水平显示*/
            color:white;
            font-size: 18px;
            font-family:"微软雅黑";
            text-align:center;
            line-height: 45px;
            border-right:1px solid #000;
        }
        #logo ul li a{
            color:white;/* #fff */
            font-size:18px;
            font-family:"微软雅黑";
            text-decoration:none;
        }
        #logo ul li:hover{
            background:rgba(10,5,5,0.45);
        }
        #logo ul li.first:hover{
            border-radius:10px 0px 0px 10px;/*左上 左下 圆弧显示 */
        }
        #logo ul li.last:hover{
            border-radius:0px 10px 10px 0px;/*左上 左下 圆弧显示 */
        }
        #logo ul li ul li{
            border: none;
            border-top:1px solid #989898;
            background:rgba(10,5,5,0.45);/*颜色透明度 */
            border-radius:10px;
        }
        #logo ul li ul{
            display:none;
        }
        #logo ul li ul li:hover{
            background:rgba(10,5,5,0.8);/*颜色透明度 */
            border-radius:10px;
        }
        #logo ul li:hover ul{
            display: block;
            -webkit-animation:roll 1s ease;
        }
        @-webkit-keyframes roll {
            from{
                -webkit-transform: rotate(0deg);
            }
           to{-webkit-transform:rotate(360deg);}
        }
    </style>
</head>
<body>
    <div id="logo">
        <ul>
            <li class="first">
                <a href="#">网址</a>
                <ul>
                    <li>
                        <a href="http://www.baidu.com">百度</a>
                    </li>
                    <li>
                        <a href="http://www.sina.com">新浪</a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="#">英语</a>
            </li>
            <li>
                <a href="#">数学</a>
            </li>
            <li>
                <a href="#">音乐</a>
            </li>
            <li>
                <a href="#">地图<a>
            </li>
            <li class="last" style="border:none;">
                <a href="#">关于<a>
            </li>
        </ul>

    </div>
</body>
</html>
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,以下是实现一个类似于Vivo官网的导航栏的 HTML + CSS + JS 代码: HTML: ```html <nav class="navbar"> <a href="#" class="navbar-logo">Vivo</a> <ul class="navbar-menu"> <li><a href="#">首页</a></li> <li><a href="#">产品</a></li> <li><a href="#">服务</a></li> <li><a href="#">社区</a></li> <li><a href="#">关于</a></li> </ul> <div class="navbar-search"> <input type="text" placeholder="搜索"> <button>搜索</button> </div> <button class="navbar-toggle"> <span class="navbar-toggle-icon"></span> </button> </nav> ``` CSS: ```css .navbar { display: flex; justify-content: space-between; align-items: center; padding: 20px; background-color: #fff; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); z-index: 999; } .navbar-logo { font-size: 24px; font-weight: bold; color: #333; text-decoration: none; } .navbar-menu { display: flex; justify-content: flex-end; align-items: center; margin: 0; padding: 0; list-style: none; } .navbar-menu li { margin-left: 20px; } .navbar-menu li a { font-size: 16px; color: #333; text-decoration: none; } .navbar-menu li a:hover { color: #f00; } .navbar-search { display: none; } .navbar-search input[type="text"] { border: none; padding: 10px; margin-right: 10px; border-radius: 5px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .navbar-search button { border: none; padding: 10px; background-color: #f00; color: #fff; border-radius: 5px; cursor: pointer; } .navbar-toggle { display: none; border: none; background-color: transparent; cursor: pointer; } .navbar-toggle-icon { display: block; width: 20px; height: 2px; background-color: #333; margin: 3px 0; transition: all 0.3s ease-in-out; } .navbar-toggle-icon:first-child { margin-top: 0; } .navbar-toggle-icon:last-child { margin-bottom: 0; } .navbar-fixed { position: fixed; top: 0; left: 0; width: 100%; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .navbar-fixed .navbar-search { display: block; } .navbar-fixed .navbar-menu { display: flex; flex-direction: column; justify-content: center; align-items: center; position: fixed; top: 70px; left: 0; width: 100%; height: calc(100vh - 70px); background-color: #fff; transition: all 0.3s ease-in-out; z-index: 998; } .navbar-fixed .navbar-menu li { margin-left: 0; margin-bottom: 20px; } .navbar-fixed .navbar-menu li a { font-size: 24px; color: #333; text-decoration: none; } .navbar-fixed .navbar-menu li a:hover { color: #f00; } .navbar-fixed .navbar-toggle { display: block; } .navbar-fixed .navbar-toggle-icon:first-child { transform: rotate(45deg) translate(6px, 6px); } .navbar-fixed .navbar-toggle-icon:last-child { transform: rotate(-45deg) translate(6px, -6px); } .navbar-fixed .navbar-toggle-icon:nth-child(2) { opacity: 0; } ``` JavaScript: ```javascript var navbar = document.querySelector('.navbar'); var navbarOffsetTop = navbar.offsetTop; var navbarToggle = document.querySelector('.navbar-toggle'); function onScroll() { if (window.pageYOffset >= navbarOffsetTop) { navbar.classList.add('navbar-fixed'); } else { navbar.classList.remove('navbar-fixed'); } } window.addEventListener('scroll', onScroll); navbarToggle.addEventListener('click', function() { navbar.classList.toggle('navbar-menu-open'); }); ``` 以上代码实现了一个类似于Vivo官网的导航栏,具有响应式布局和下拉菜单功能。当页面滚动时,导航栏会固定在页面顶部并且搜索框和下拉菜单会出现。在移动设备上,用户可以点击菜单按钮打开下拉菜单。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值