0

我有一个 div 导航栏,我希望它填充页面宽度上的所有空间。我试过使用 margin-left 和 margin-right 但它没有用。知道这是如何实现的吗?

这是我尝试过的:

.nav{
    background-color: #2EC0FE;
    opacity: 0.75;
        -moz-box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
        -webkit-box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
    box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
    background-image: -o-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: -moz-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: -webkit-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: -ms-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    height: 100px;
    width: cover;
    margin-top: 500px;
    margin-left: 0px;
    margin-right: 0px;
}

编辑:

HTML:

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="style.css">
        <!--<img src="hksquared.jpg" id="bg" alt="">-->
    </head>
    <body>
        <div class="nav"></div>
        <footer></footer>
    </body>
</html>

谢谢

4

1 回答 1

0

像这样?

HTML:

<body>
    <div class="nav">a</div>
</body>

CSS:

.nav {
    background-color: #2EC0FE;
    opacity: 0.75;
    -moz-box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
    -webkit-box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
    box-shadow: 0px 0px 0px rgba(0,0,0,1), inset 0px 0px 0px rgba(0,0,0,1);
    background-image: -o-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: -moz-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: -webkit-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: -ms-linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    background-image: linear-gradient(90deg , rgb(0,0,0) 0%, rgb(0,0,0) 100%);
    height: 100px;
    width: 100%;
}

演示

于 2013-09-06T05:48:07.880 回答