响应式游戏网站之首页导航制作

本文分享了如何利用Bootstrap框架创建一个游戏网站的导航栏,包括详细的HTML和CSS代码,展示了响应式设计和下拉菜单的实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

看到一个风格很喜欢的游戏网站,准备试着用bootstrap做一下,正好最近在学习bootstrap。今天记录一下首页导航部分:
在这里插入图片描述图上是效果图,下面附代码:
html:

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
    <title>Home 01 || Gilbard</title>
    <!-- Place favicon.ico in the root directory -->
    <link href="assets/images/favicon.ico" type="img/x-icon" rel="shortcut icon">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/qanto.css">
    <link rel="stylesheet" href="assets/css/bauhaus93.css">
    <link rel="stylesheet" href="assets/css/font-awesome.min.css">
    <link rel="stylesheet" href="assets/css/icofont.min.css">
    <link rel="stylesheet" href="assets/css/plugins.css">
    <link rel="stylesheet" href="assets/css/helper.css">
    <link rel="stylesheet" href="assets/css/style1.css">
    <!-- Modernizr JS -->
    <script src="assets/js/vendor/modernizr-2.8.3.min.js"></script>
</head>
<body>
<div id="main-wrapper">
    <header class="header">
        <div class="container container-1520">
            <div class="row">
                <div class="col-lg-3 logo">
                    <a href="index.html" style="display: inline-block;">
                        <img src="assets/images/logo.png">
                    </a>
                </div>
                <div class="col-lg-6">
                    <nav class="nav-menu">
                        <ul>
                            <li>
                                <a href="index.html">Home</a>
                                <ul class="sub-menu">
                                    <li> <a href="index.html">Home One</a></li>
                                    <li> <a href="index.html">Home Two</a></li>
                                    <li> <a href="index.html">Home Three</a></li>
                                    <li> <a href="index.html">Home Four</a></li>
                                    <li> <a href="index.html">Home Five</a></li>
                                    <li> <a href="index.html">Home Six</a></li>
                                </ul>
                            </li>
                            <li>
                                <a href="index.html">Games</a>
                                <ul class="sub-menu">
                                    <li> <a href="index.html">Home One</a></li>
                                    <li> <a href="index.html">Home Two</a></li>
                                    <li> <a href="index.html">Home Three</a></li>
                                    <li> <a href="index.html">Home Four</a></li>
                                    <li> <a href="index.html">Home Five</a></li>
                                    <li> <a href="index.html">Home Six</a></li>
                                </ul>
                            </li>
                            <li>
                                <a href="index.html">videos</a>
                                <ul class="sub-menu">
                                    <li> <a href="index.html">Home One</a></li>
                                    <li> <a href="index.html">Home Two</a></li>
                                    <li> <a href="index.html">Home Three</a></li>
                                    <li> <a href="index.html">Home Four</a></li>
                                    <li> <a href="index.html">Home Five</a></li>
                                    <li> <a href="index.html">Home Six</a></li>
                                </ul>
                            </li>
                            <li>
                                <a href="index.html">forums</a>
                                <ul class="sub-menu">
                                    <li> <a href="index.html">Home One</a></li>
                                    <li> <a href="index.html">Home Two</a></li>
                                    <li> <a href="index.html">Home Three</a></li>
                                    <li> <a href="index.html">Home Four</a></li>
                                    <li> <a href="index.html">Home Five</a></li>
                                    <li> <a href="index.html">Home Six</a></li>
                                </ul>
                            </li>
                            <li>
                                <a href="index.html">pages</a>
                                <ul class="sub-menu">
                                    <li> <a href="index.html">Home One</a></li>
                                    <li> <a href="index.html">Home Two</a></li>
                                    <li> <a href="index.html">Home Three</a></li>
                                    <li> <a href="index.html">Home Four</a></li>
                                    <li> <a href="index.html">Home Five</a></li>
                                    <li> <a href="index.html">Home Six</a></li>
                                </ul>
                            </li>
                            <li>
                                <a href="index.html">contact</a>
                                <ul class="sub-menu">
                                    <li> <a href="index.html">Home One</a></li>
                                    <li> <a href="index.html">Home Two</a></li>
                                    <li> <a href="index.html">Home Three</a></li>
                                    <li> <a href="index.html">Home Four</a></li>
                                    <li> <a href="index.html">Home Five</a></li>
                                    <li> <a href="index.html">Home Six</a></li>
                                </ul>
                            </li>
                        </ul>
                    </nav>
                </div>
                <div class="col-lg-3">
                    <ul class="header-right">
                        <li><a href="login.html">LOGIN</a></li>
                        <li><a href="register.html">register</a></li>
                        <li>
                            <a class="search" href="#">
                                <i class="icofont-search-2"></i>
                            </a>
                            <div class="header-search" style="display: none;">
                                <form action="#">
                                    <input type="text" placeholder="Type and hit enter">
                                    <button>
                                        <i class="icofont-search"></i>
                                    </button>
                                </form>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </header>
</div>
<!-- All jquery file included here -->
<script src="assets/js/vendor/jquery-1.12.4.min.js"></script>
<script src="assets/js/popper.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/plugins.js"></script>
<script src="assets/js/main1.js"></script>
</body>
</html>

css:

@import url("https://fonts.googleapis.com/css?family=Ubuntu:300,400,500");
body,html{
height: 100%;
}
*{
    box-sizing: border-box;
}
a, button, img, input, span{
    transition: all 0.3s ease 0s
}
a,button{
    cursor: pointer;
    text-decoration: none;
}
ul{
    padding: 0;
    margin: 0;
}
li{
    list-style: none;
}
a:hover{
    text-decoration: none;
}
.row{
    align-items: center;
}
body{
    background-color: #ffffff;
    font-size: 15px;
    font-style: normal;
    font-weight: normal;
    font-family: "Ubuntu", sans-serif;
    color: #151515;
    position: relative;
}
/*start header*/
.header{
    width: 100%;
    background-color: black;
}
@media only screen and (min-width: 1200px) and (max-width: 1499px) {
    .container.container-1520 {
        max-width: 1200px; } }
@media only screen and (min-width: 992px) and (max-width: 1199px) {
    .container.container-1520 {
        max-width: 960px; } }
@media only screen and (min-width: 768px) and (max-width: 991px) {
    .container.container-1520 {
        max-width: 720px; } }
@media only screen and (max-width: 767px) {
    .container.container-1520 {
        max-width: 540px; } }
@media only screen and (max-width: 479px) {
    .container.container-1520 {
        max-width: 300px; } }
.header .container .logo{
    margin: 20px 0;
}
.nav-menu>ul{
    display: flex;
    list-style: none;
}
.nav-menu>ul>li{
    margin-right: 40px;
    position: relative;
}
.nav-menu ul li a{
    line-height: 30px;
}
.nav-menu>ul>li>a{
    font-size: 20px;
    font-weight: 400;
    letter-spacing: 0.25px;
    font-family: "Qanto";
    color: #ffffff;
    display: block;
    padding: 30px 0;
    position: relative;
    text-transform: capitalize;
}
.nav-menu>ul>li:hover>a{
    color: #f64140;
}
.sub-menu{
    visibility: hidden;
    position: absolute;
    left: 0;
    top: 100%;
    margin-left: -20px;
    padding: 20px 0;
    background-color: #fff;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease 0s;
    width: 210px;
    z-index: 666;
    opacity: 0;
}
.sub-menu li{
    margin-bottom: 5px;
}
.sub-menu li a{
    letter-spacing: 0.25px;
    font-family: "Qanto";
    color: #151515;
    display: block;
    font-size: 14px;
    font-weight: 400;
    padding: 0 20px;
}
.sub-menu li:hover a{
    padding-left: 25px;
    color: #f64140;
}
.nav-menu ul li:hover .sub-menu{
    visibility: visible;
    opacity: 1;
}
.header-right {
    text-align: right;
}
.header-right li{
    display: inline-block;
    margin-right: 25px;
}
.header-right li a{
     font-size: 20px;
     line-height: 30px;
     display: block;
     padding: 30px 0;
     font-family: "Qanto";
     color: #9f9f9f;
 }
.header-right li a:hover{
    color: #fff;
}
.header-right li:last-child{
    margin-right: 0;
}
.header-right i{
    font-size: 24px;
}
a .search{
    background-color: transparent;
    border: none;
    width: 30px;
    height: 30px;
}
@media only screen and (min-width: 1200px) and (max-width: 1499px) {
    .header-search {
        right: 10px; } }
div .header-search{
    position: absolute;
    top: 100%;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
}
.header-search form{
    display: flex;
}
.header-search form input{
    width: 250px;
    border: none;
    background-color: transparent;
    color: #151515;
    line-height: 24px;
    padding: 13px 20px;
}
.header-search form button {
    line-height: 24px;
    padding: 13px 15px;
    border: none;
    background-color: #061da4;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    color: #ffffff;
    -webkit-transition: all 0.3s ease-in-out;
    -o-transition: all 0.3s ease-in-out;
    transition: all 0.3s ease-in-out;
}
.header-search form button:hover{
    background-color: #000000;
}
.header-search form button i{
    font-size: 24px;
    line-height: 24px;
}
/*end  header*/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值