我在设计一个网页,但我是一个HTML/CSS的新手。我想要以下格式:如何在两个div之间添加空格?
上半部分和下半部分。
上半部分包含6个大箱子,组织成两列3个箱子。
下半部分包含一些其他内容,无论我想要什么。
现在我(以某种方式)使它工作,但唯一的是“bottom_half”太接近“top_half” - 我只是想在它们之间增加一点余量。但是当我试图做那些奇怪的事情会发生,我不明白我做错了什么。
这里是我的html布局的轮廓:
<div class="top_half">
<div class="left_half">
<div class="big_box">
<!-- box 1 content -->
</div>
<div class="big_box">
<!-- box 2 content -->
</div>
<div class="big_box">
<!-- box 3 content -->
</div>
</div> <!-- left-half -->
<div class="right_half">
<div class="big_box">
<!-- box 4 content -->
</div>
<div class="big_box">
<!-- box 5 content -->
</div>
<div class="big_box">
<!-- box 6 content -->
</div>
</div> <!-- right-half -->
</div> <!-- top-half -->
<div class="bottom_half">
<!-- bottom-half content -->
</div>
我对于顶部和底部的一半CSS是这样的:
.top_half {
height: auto;
width: auto;
margin-top: 70px;
padding-top: 70px;
background: lightgreen
}
.bottom_half {
height: auto;
width: auto;
margin-top: 70px;
padding-top: 70px;
background: lightyellow;
}
奇怪的是,top_half DIV是在只是一个漂亮的小酒吧页面顶部,bottom_half div基本上占据了整个页面。
我的布局不好吗?我应该以不同的方式做吗?我真的没有这方面的经验,所以我一直在学习。
谢谢!
编辑:
修正了一些错别字。看看这个,看看我的意思:https://jsfiddle.net/d7ejv3ad/3/ ^^为什么不是绿色的酒吧里面的灰色框?
您在CSS中有.bottom_half,但在html中有.bottom-half。 –
我建议投票结束,因为这个错误是由错别字造成的。 –
废话 - 对不起,这些错别字不在我的实际代码中,但他们在我复制到本网站的代码中!即使错别字已修复,也是同样的问题(我编辑原文) – ineedahero