删除HTML页面顶部10px的边距
我有一个非常简单的HTML页面和一个非常简单的样式表。页面顶部有10px的边距,不会消失。以下是我的布局和风格:删除HTML页面顶部10px的边距,html,css,Html,Css,我有一个非常简单的HTML页面和一个非常简单的样式表。页面顶部有10px的边距,不会消失。以下是我的布局和风格: html, body { padding: 0; margin: 0; margin-top: -10px; } .main-container { with: 100%; } .left-column { width: 25%; float: left; background-color: lightblue; height: 500
html, body {
padding: 0;
margin: 0;
margin-top: -10px;
}
.main-container {
with: 100%;
}
.left-column {
width: 25%;
float: left;
background-color: lightblue;
height: 500px;
display: inline-block;
}
这是我的HTML
<!DOCTYPE html>
<html>
<head>
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<main class="main-container">
<aside class="left-column">
</aside><!-- .left-column -->
<section class="news-feed">
<article class="story-item">
<header class="story-title">
<h1>This is the title of the post</h1>
</header><!-- .story-title -->
<p class="story-details">
This is the body of the post
</p>
</article><!-- .story-item -->
</section><!-- .news-feed -->
</main><!-- .main-container -->
</body>
</html>
试试这个
body {
margin: 0 !important;
padding: 0 !important;
}
试试这个
body {
margin: 0 !important;
padding: 0 !important;
}
使用reset或normalise.css 否则,这将正常工作
body {
margin:0;
padding:0;
}
使用reset或normalise.css 否则,这将正常工作
body {
margin:0;
padding:0;
}
H1标签的标准边距为10px,这导致了这种情况。尝试重置:
*,html,body {
margin:0;
padding:0;
}
*字符是一个全局选择器。H1标记的标准边距为10px,这就是原因。尝试重置:
*,html,body {
margin:0;
padding:0;
}
*字符是全局选择器。您的问题是h1标记上的默认样式使用:
h1 {margin:0px;}
您的问题是h1标记上的默认样式使用:
h1 {margin:0px;}
这可能是您无法控制的特定于浏览器的问题。你可以试试边距:0!重要的填充:0!重要的这可能会否决用户样式。将h1页边距设为顶部:0您在哪个浏览器中看到此内容?这是由float:left in.left column引起的问题!这可能是您无法控制的特定于浏览器的问题。你可以试试边距:0!重要的填充:0!重要的这可能会否决用户样式。将h1页边距设为顶部:0您在哪个浏览器中看到此内容?这是由float:left in.left column引起的问题!就这样!谢谢我会在5分钟内给你打勾,期限到了,就是这样!谢谢我会在5分钟内给你打勾,期限到了!重要的是,尤其是在这种情况下,坏习惯是很重要的。!重要的是,特别是在这种情况下,坏习惯是很重要的。