css - 黑白导航栏和内容栏,经过一些调试后找不到问题

标签 css

Image of the resultant template

你好,我想问我不明白为什么导航栏和内容框的边缘空间是黑色的我仔细检查了尝试使用 chrome 进行一些调试但仍然发现了导致此错误的原因..代码如下:

/*css code*/
    #header{
    
        height: 85px;
        padding: 0px 50px 0px 50px;
        margin-left: 200px;
        margin-right: 200px;
        border-radius: 20px;
        background-color: cyan;
        border-bottom-left-radius: 0px;
        border-bottom-right-radius: 0px;
        
    }
    body{
        background-image: url(gods_of_egypt_elodie_yung-3840x2160.jpg);
    	background-attachment: fixed;
        background-repeat: no-repeat;
        background-size: cover;
     
    }
    #heading{
        color: aliceblue;
        font-size: 70px;
    
        text-align: center;
    	margin: 0px;
    }
    #navbar{
     
        background-color: grey;
        margin: 0px 200px 0px 200px;
    	height: 30px;
    	overflow: hidden
    
      
    }
    ul{
        padding: 0px;
        margin: 0px;
    	font-family: arial;
    }
    li{
    	display: inline;
    }
    a{
    	display: block;
        text-align: center;
    	float: left;
    	width: 100px;
    	padding: 3px;
    	line-height: 25px;
    	text-decoration: none;
    	color: white;
    	margin-top: 0px;
    }
    a:hover{
    	background-color: #d3d3d3;
    	color: black;
    }
    /*
    #searchbar{
    	
    	margin-left: 250px;
    	margin-top: 4px;
    	margin-bottom: 0px;
    }*/
    #content{
    	background-color: white;
    	height: 400px;
    	margin: 0px 200px 0px 200px;
    }
     <html>
    <link rel="stylesheet" href="stylesheet.css">
    <body>
    
    
        <div id="header">
            <h1 id="heading">#Some Stuff</h1>
        </div>
        <div id="navbar">
           <ul>
               <li><a href="#">Home</a></li>
               <li><a href="#">Products</a></li>
               <li><a href="#">More</a></li>
               <li><a href="#">About US</a></li>
            </ul>
    </div>
        <div id="content">
    	<p>WOW!
    	</p>
    	</content> 
    	
    	</body>
    </html>


    

请帮助解决这个问题因为我完全不知道为什么我卡在这里

最佳答案

快速:

#content p
{
    margin:0px;
}

解释

默认情况下,某些浏览器会自动为标签设置边距。

例如 body

margin: 8px;

在标签上。在您的代码中,您可以简单地添加:

body {
     background-image: url(gods_of_egypt_elodie_yung-3840x2160.jpg);
     background-attachment: fixed;
     background-repeat: no-repeat;
     background-size: cover;

     margin: 0px; //THIS LINE HERE!
     }

标签也一样

p {
display: block;
-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;
}

所以,你也可以强制

 margin:0px;

关于css - 黑白导航栏和内容栏,经过一些调试后找不到问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52261184/

相关文章:

jquery - 如何将 CSS 应用于在 jQuery 对话框中打开的 HTML 页面?

html - css 更改正文未显示在 html 中

html - 具有图像和文本样式的 Div

javascript - 获取同一类元素内的图像属性

css - 带一个圆 Angular 的三 Angular 形

html - 取决于内容的可变 html 列高度

javascript - 没有带有 ExtractTextPlugin 的 js 源映射

html - 添加填充时如何在 div 宽度和高度上调整内容,不让滚动条出现

javascript - jQuery:滚动到 <div> 中的位置时的目标位置 "changes"

html - CSS 表格单元格大小问题