因此,每当我从头开始编写新的Tumblr主题时,帖子正文总是会在帖子的标题/正文的顶部和底部添加不需要的填充。这不会出现在引用帖子和聊天帖子中,但会出现在文本,照片,照片集,视频和音频帖子中。我猜这是Tumblr自动为你做的事情,因为当我测试一个类似的代码时,它运行良好,并没有在顶部和底部添加额外的填充。我该如何解决这个问题?谢谢你的帮助!
HTML:
<div id="holder">
<div class="post">
<div class="body">
words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words
</div>
</div>
<div class="post">
<div class="body">
words words words words words words words words words words words words words words words words words words words words words words words words words words words words words words
</div>
</div>
CSS:
#holder {
position: relative;
margin: 40px auto 0 auto;
padding: 20px;
width: 400px;
height: 500px;
background: red;
}
#holder .post {
margin-bottom: 20px;
padding: 20px;
background: green;
}
答案 0 :(得分:3)
你确定你在谈论填充吗?我相信你实际意味着浏览器为段落设置的初始边距(所谓的用户代理样式)。您可以像这样删除它:
p {
margin: 0;
}
但是为了在段落之间保留一些空间,你可以这样做:
p {
margin-top: 0;
margin-bottom: 20px;
}