html - 涵盖主要站点内容的导航菜单

标签 html css web-deployment-project

我网页的导航菜单覆盖了网站的主要内容/内容(父级内部的内容)。 当我向导航栏或父级添加边距时,导航栏会随着父级中的图像/内容向下移动。 下面是代码:

<html>
<head>
    <title>Digital Ethics</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="white">
    <div class="outer">
        <div class="nav">
            <div class="pic"><img src="logo.png" /><br><p><p></div>
            <div class="nav-bar">
                <ul>
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About Us</a></li>
                    <li><a href="#">Contact Us</a></li>
                    <li><a href="#">Services</a></li>
                </ul>
            </div>
        </div>
        <div class="parent">
            <div class="bimg"></div>
            <div>
            <div></div>
            <div></div>
            </div>
        </div>
    </div>
</body>
</html>

CSS

body {
    background-image: url("background.jpg");        
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    margin: 0px;
}

.outer {
    width:100%px;
    height: auto;
    margin: 0px;
}

.nav {
    width: 100%;
    height: 180px;
    display: inline-block;
    background-color: white;
    position: fixed;
    margin-top: -30px;

}
.nav .pic{
    width: 40%
    float: left;
    display: inline-block;
    margin-left: 60px
}
.nav .pic p{
    color: a5a5a5;
    margin-left: 10px;
}
.nav-bar{
    width: 60%;
    float: right;
    margin-top: 45px;
}
.nav-bar ul{
    list-style-type: none;
}
.nav-bar li{
    background-color: transparent;
    display: inline-block;
    padding: 10px;
    width: 150px;
    text-align: center;
    text-transform: uppercase;
    font-weight: bold;
}
.nav-bar a{
    color: #4f4946;
    text-decoration: none;
}

.nav-bar a:hover{
    color: #eb4934;
    transition: 0.75s ease-out;
}

.nav-bar a:active{
    color: #eb4934;
    transition: 0.75s ease-out;
}


.parent {
    height: auto;
    width: 80%;
    background-color: white;
    margin-top: 180px;
}

.bimg {
    background-image: url("img.jpg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    height: 200px;
    width: 100%;
}

请帮忙, 提前致谢。

最佳答案

这是添加部分响应...

ul {
  display: flex;
  width: none;
  white-space: nowrap;
}

关于html - 涵盖主要站点内容的导航菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38656561/

相关文章:

c# - 如何在使用 VS MSI 安装程序安装之前备份 Web.config

zend-framework - 在子目录主机上部署模块化 zend 项目

html - 谁能告诉我如何用 HTML/CSS 插入这个

css - 如何防止大字体在 Chrome (OSX) 中看起来呈锯齿状?

html - 我在 CSS 中的媒体查询没有切换容器

javascript - css 类切换不切换类

javascript - CSS从IFrame弹出窗口

css - Div 和图层

javascript - 使用 jquery 的音频播放器