导航链接在缩放上彼此顶部

时间:2014-09-16 06:07:29

标签: html css

似乎当我放大浏览器时,我的导航按钮完全相互重叠。检查以下图像:
正常:http://i.imgur.com/yFxwrXw.png
缩放:http://i.imgur.com/OnUP6Sg.png

有没有人知道防止这种情况的方法/阻止这种情况发生?

body {
    width: 100%;
    height: 100%;
    padding: 0;
    max-width: 960px;
    margin: 10px auto 0;
    background: #1b1b1b url('../img/bg.jpg') no-repeat fixed top center;
}

.logo {
    margin-bottom: 10px;
    margin: auto;
    width: 524px;
}

.nav {
    height: 37px;
    background-color: rgba(26,26,26,0.8);
    border: 1px solid black;
    margin-bottom: 10px;

}

ul {
    margin: 0;
    padding: 0;
    text-align: center;
    line-height: 38px;
}

ul li {
    display: inline;
    color: #828282;
    padding: 0.4166666666666667% 2.5%;
    background: #595959;
    margin: 0 10px;
    border:1px solid #828282;

}

ul li a {
    text-decoration: none;
    color: white;
    font-family: arial;
}

ul li a:hover {

}

.main {
    width: 99.79166666666667%;
    min-height: 50%;
    height: auto;
    background-color: rgba(26,26,26,0.8);
    border: 1px solid black;
}


    <html>
    <head>
        <link rel="stylesheet" href="style/style.css" />
    </head>
    <body>
        <div class="logo">
            <img src="img/logo.png"></div>
        <div class="nav">
            <ul>
                <li><a href="">HOME</a></li>
                <li><a href="">PRODUCTS</a></li>
                <li><a href="">SHOPS</a></li>
                <li><a href="">FAQ</a></li>
                <li><a href="">ABOUT US</a></li>
            </ul>
        </div>
        <div class="main">
        </div>
    </body>
    </html>

1 个答案:

答案 0 :(得分:1)

body {
    width: 100%;
    height: 100%;
    padding: 0;
    min-width: 960px; /* Change max-width to min-width */
    margin: 10px auto 0;
    background: #1b1b1b url('../img/bg.jpg') no-repeat fixed top center;
}

在正文中设置min-width: 960px;

DEMO

这是Fiddle