html - 上边距不起作用

标签 html css

对不起,我是 CSS 新手。我有以下 html:

<div class="box-A" >Box A is here</div>
 <div class="box-B" >Box B is here</div>

并且我尝试将以下 css 应用到它:

.box-A{
    background-color: red;
    padding: 30px;
    margin: auto;
    border: 13px solid green;
    margin-bottom: 40px;
}

.box-B{
    background-color: blue;
    padding: 40px;
    margin-top: 140 px;
}

当我将 margin-top: 140 px; 应用于 box-B 时,它对 box-A 正常工作,我希望看到2 个框之间的边距约为 180px。 但是没有任何反应。你能告诉我为什么 margin-top 没有效果吗?

最佳答案

不要在 px 和数字之间使用空格。

.box-B{
    background-color: blue;
    padding: 40px;
    margin-top: 140px;
}

关于html - 上边距不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38409492/

相关文章:

html - 没有为父 div 设置 box-shadow

html - 防止流体容器内右定位的 div 换行

javascript - 单击子元素时阻止父类

android - 从WebView获取网站源码

html - CSS 文件未加载

html - 错误类型错误 : Cannot read property 'ID' of undefined (Angular 8)

Jquery 没有显示所有增强的动态附加单选按钮

javascript - 如何在一周中的几天之间更改照片?

javascript - 宽度为 auto 的内联 block 元素不会更新

html - CSS - 通过网站结构而不是大量类来设计网站样式