阴阳师官网导航栏 html+css

阴阳师官网导航栏

通过css html实现阴阳师官网的顶部导航栏

具体样式
在这里插入图片描述

下拉列表

下拉列表的实现

下面一起看看代码

<div class="header">
        <div class="menu">游戏全目录</div>
        <a href="#">
            <img src="images/logo_b5525b7.png" alt="">
        </a>
        <div class="sale">25元专属券限时领!</div>
    </div>
    <!--头部结束-->
    <!--导航开始-->
    <div class="nav">
        <div class="nav-wrap">
            <ul>
                <li class="nav-active"><a href="#">官网首页</a></li>
                <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>
                <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>
                <li><a href="#">官网首页</a></li>
                <li><a href="#">官网首页</a></li>
                <li><a href="#">官网首页</a></li>
            </ul>
            <div class="search"></div>
        </div>
        <div class="nav-list">
            <a href="#">
                <img src="images/ss_4_645f86e.jpg" alt="">
            </a>
            <a href="#">
                <img src="images/ss_4_645f86e.jpg" alt="">
            </a>
            <a href="#">
                <img src="images/ss_4_645f86e.jpg" alt="">
            </a>
            <a href="#">
                <img src="images/ss_4_645f86e.jpg" alt="">
            </a>
            <a href="#">
                <img src="images/ss_4_645f86e.jpg" alt="">
            </a>
        </div>
    </div>

CSS样式表

/*头部样式开始*/
.header {
    position: relative;
    width: 100%;
    height: 55px;
    /*一行文字垂直居中*/
    line-height: 55px;
}

.menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 179px;
    height: 54px;
    background-color: #cf1132;
    font-size: 12px;
    color: #fff;
}

.sale {
    position: absolute;
    top: 0;
    right: 0;
    width: 138px;
    border-left: 1px solid #dadada;
    height: 54px;
    color: #333;
    font-size: 12px;
    /*修改光标为小手*/
    cursor: pointer;
}

.sale:hover {
    color: #bc2e2e;
    border-bottom: 1px solid #bc2e2e;
    background-color: #f3f3f3;
}

/*头部样式结束*/
/*banner样式开始*/
.banner {
    position: relative;
    top: -10px;
    width: 100%;
    height: 784px;
}

.nav {
    z-index: 999;
    /*相对定位  相对于自己原位置不移动
    固定定位  相对于浏览器窗口的位置 0 0*/
    /*
    有粘性定位的元素的父元素不能设置overflow:hidden|auto|scroll;
    */
    position: sticky;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: url("../images/nav_back_bg_fd2505e.jpg") no-repeat center top;
}

.nav-wrap {
    position: relative;
    margin: 0 auto;
    width: 1180px;
    height: 70px;
    line-height: 70px;
}

.nav-wrap li {
    position: relative;
    float: left;
    width: 84.28px;
    font-size: 14px;
}

.nav-wrap li:not(.nav-active)::after {
    position: absolute;
    top: 30px;
    right: 0;
    content: "";
    width: 1px;
    height: 10px;
    background-color: #fff;
}

.nav-wrap li:hover::after {
    content: "";
    background-color: transparent;
}

.nav-wrap a {
    color: #fff;
}

.nav-active {
    background: url("../images/nav_bg1_d44f09d.jpg") no-repeat;
}

.nav-active > a {
    color: #000;
}

.nav-wrap li:hover {
    background: url("../images/nav_bg1_d44f09d.jpg") no-repeat;
}

/*鼠标悬停到li上 它的儿子a  字体颜色变为黑色*/
.nav-wrap li:hover > a {
    color: #000;
}

/*放大镜*/
.search {
    /*相对于nav-wrap定位*/
    position: absolute;
    top: 25px;
    right: -35px;
    width: 18px;
    height: 19px;
    background: url("../images/search_b180dd5.png") no-repeat;
    transition: all .3s;
}

.search:hover {
    transform: rotateY(180deg);
}

/*下拉列表*/
/*
思路:
①下拉列表绝对定位到显示的位置
②display:none; 隐藏
③鼠标悬停显示 display:block;
*/
.nav-list {
    position: absolute;
    top: 60px;
    left: 0;
    width: 100%;
    height: 0px;
    overflow: hidden;
    transition: all .3s;
    background: url("../images/subnav_bg_5cc9309.jpg") center 0 no-repeat;
}

.nav:hover > .nav-list {
    height: 140px;
}

.nav-list img {
    margin: 24px 10px 0;
}
可以使用 flex 盒子模型来编写一个简单的网易阴阳师导航栏,以下是一个示例代码HTML 代码: ```html <div class="nav"> <div class="nav-logo"> <img src="logo.png" alt="网易阴阳师"> </div> <ul class="nav-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> <li><a href="#">商城</a></li> </ul> <div class="nav-search"> <input type="text" placeholder="请输入关键字"> <button>搜索</button> </div> </div> ``` CSS 代码: ```css .nav { display: flex; justify-content: space-between; align-items: center; padding: 20px; background-color: #f7f7f7; } .nav-logo img { width: 100px; } .nav-menu { display: flex; justify-content: center; align-items: center; list-style: none; } .nav-menu li { margin: 0 10px; } .nav-menu a { text-decoration: none; color: #333; font-size: 16px; } .nav-search { display: flex; align-items: center; } .nav-search input { padding: 5px; border: none; border-radius: 5px 0 0 5px; } .nav-search button { padding: 5px 10px; border: none; background-color: #f00; color: #fff; border-radius: 0 5px 5px 0; } ``` 说明: 1. 使用 `display: flex` 将导航栏容器设置为 flex 布局。 2. 使用 `justify-content: space-between` 让 logo、菜单和搜索框之间平均分布。 3. 使用 `align-items: center` 让 logo、菜单和搜索框在垂直方向上居中对齐。 4. 使用 `list-style: none` 去掉菜单项的默认样式。 5. 使用 `margin: 0 10px` 让菜单项之间有一定的距离。 6. 使用 `text-decoration: none` 去掉菜单项链接的下划线。 7. 使用 `padding` 和 `border` 属性美化搜索框和按钮的样式。 8. 使用 `border-radius` 属性让搜索框和按钮的边角变为圆角。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

玄东林檎

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值