html - body 上不需要的 48px 边距?

标签 html css margin

我正在构建一个用于创建 wordpress 主题的静态 html 页面。但现在我注意到 48px 边距在 body 元素上方(我用 chrome 开发人员工具找到了它)。我可以通过添加 -48px 边距来修复它但是究竟是什么导致了这个问题,谁能帮帮我。

我的CSS

body{
    font-size:18px;
    line-height:1.72222;
    color:#34495e;
    font-family:Ubuntu;
    margin:0
}
aside {
    background: #31373d;
    height: 100%;
    position: fixed;
    width: 20%;
    font-weight: normal;
    color:#fff;
}
.main {
    margin-left: 20%;
}
.content{
    width: 65%;
    max-width: 760px;
    margin: 3rem auto;
}

看看这个实时 JSfiddle 演示 - http://jsfiddle.net/aq96b/1/embedded/result/

最佳答案

就是这条线

margin: 3rem auto;

在导致此问题的 .content 中(如果我正确理解问题)。取消选中/删除该边距会将内容移回 .main div 的左上角。

为了与内容位置保持相似的效果,您可以向 .main 添加相同数量的填充,即

padding: 3em;

关于html - body 上不需要的 48px 边距?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21113385/

相关文章:

html - 带有 CSS 的弹出式搜索框

javascript - 在ajax Jquery中发送多部分数据

javascript - Facebook 链接在页面中创建空白

css - 如何使 google +1 按钮悬停消息透明

css - 在容器中居中放置 2 个 div(向左、向右浮动)

html - 表单帖子中字段的大小限制是多少?

jquery - 使用 jquery addclass 将 css 添加到表中

javascript - Masonry:使用 2 列布局,如何让 1 列比另一列宽?

css - 使用骨架 css 框架时,边距出现在两种尺寸上

Python seaborn facetGrid : Is it possible to set row category label location to the left