简体   繁体   English

如何使导航遍及整个页面

[英]how to make the navigation go across the whole page

My AIM: is to make a navigation bar go across the whole screen, with a greyish colour (#839496). 我的目标是:使导航栏以灰色显示在整个屏幕上(#839496)。 And have each link/button to have a border to the left and the right of it. 并让每个链接/按钮在其左侧和右侧都有一个边框。 Just like the navigation bar on: 就像导航栏位于:

http://www.theberrics.com/dailyops http://www.theberrics.com/dailyops

However, 然而,

My Problem is: the link/button is only going across as far as is goes. 我的问题是:链接/按钮仅在尽可能远的范围内。 I want each button to go across with the width of 150px (which works fine). 我希望每个按钮的宽度都为150px(可以正常工作)。 BUT also have the grey bar continue through the whole screen horizontally (which isnt working and just displays nothing). 但是,灰色条也会在整个屏幕上水平延伸(这是行不通的,什么也不显示)。

Here is my css: 这是我的CSS:

nav {
    background-color: #839496;
    padding: 0.02px 0;
    margin-bottom: 10px;
}

nav ul {
    width: 100%; /*RIGHT HERE: i would like the whole unordered list to go across the screen. But it doesnt work*/
    position: relative;
    left:10%;
    margin: 0;
    padding-left: 100px;
}

nav li {
    float: left;

}

nav li a{
    display: block;
    width: 150px;
    background-color: #839496;
    color: #fff;
    text-align: center;
    font-weight: bold;
    text-transform: uppercase;
    padding: 5px;
    border-right: 1px solid;
    border-left: 1px solid;
}

nav a:hover {
    background-color: white;
    color: #000;
    text-decoration: underline;
}

And here is my html: 这是我的html:

    <nav>
        <ul>
            <li><a href="index.html">Home</a><li>
            <li><a href="Top10.html">Top 10</a></li>
            <li><a href="Skaters.html">Skaters</a></li>
            <li><a href="Submit.html">Submit</a></li>
        </ul>   
    </nav>

Also: i dont want each button to be 25% of the page. 另外:我不希望每个按钮都是页面的25%。 Just 150px wide. 宽度仅为150像素。

Sorry if my code or anything i said is confusing. 对不起,如果我的代码或我所说的任何内容令人困惑。 Thank you for reading! 感谢您的阅读!

update your css like the below (ie include overflow: hidden; to nav 像下面那样更新您的CSS(即,包括overflow: hidden; nav

CSS 的CSS

nav {
    background-color: #839496;
    margin-bottom: 10px;
    overflow: hidden;
    padding: 0.02px 0;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM