我有一个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>
由于
答案 0 :(得分: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%;
}