html - CSS 基本 float 布局,页脚的 margin-top

标签 html css layout margins

我正在尝试使用 CSS 进行基本布局。

标题
旁白-内容
页脚

我为页脚设置了一个 margin-top 属性,但我不确定为什么它不起作用。这是我到目前为止的简单代码:

 

<style>

header {
	width: 100%;
 	height: 100px;
	border: 1px solid black;
	margin-bottom: 10px;
}

aside {
	width: 100px;
	height: 200px;
	border: 1px solid green;
	float: left;
	margin-right:10px;
}

article {
    height: 200px;
    width: 200px;
    border: 1px solid red;
    float: left;
}

footer {
	clear: both;
	border: 1px solid blue;
	width: 100%;
	height: 100px;
	margin-top: 10px;
}

</style>
<header> &nbsp; </header>
<aside>&nbsp;</aside>    
<article>&nbsp;</article>    
<footer>&nbsp;</footer>

您可以在此处看到页脚没有边距: http://i.imgur.com/PeeTg6I.png

最佳答案

添加显示:内联 block ;在页脚中。

<style>

header {
    width: 100%;
    height: 100px;
    border: 1px solid black;
    margin-bottom: 10px;
}

aside {
    width: 100px;
    height: 200px;
    border: 1px solid green;
    float: left;
    margin-right:10px;
}

article {
    height: 200px;
    width: 200px;
    border: 1px solid red;
    float: left;
}

footer {
    clear: both;
    border: 1px solid blue;
    width: 100%;
    height: 100px;
    margin-top: 10px;
	display: inline-block;
}

</style>
<header>
    </header>

    <aside>
    </aside>

    <article>
    </article>

    <footer>
    </footer>

关于html - CSS 基本 float 布局,页脚的 margin-top,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39652585/

相关文章:

javascript - Bootstrap 弹出框 : reload last form values

javascript - 检查邮件是否已读,gmail api

html - 在行内居中一个 div

HTML/CSS 布局 - 在 1 个图中垂直显示 2 个图像

css - 使父 div 高度反射(reflect)子 div 的填充/边框/边距的好方法是什么?

java - 列表更新后 onItemClick 停止工作

javascript - 动态添加元素时,使用 jQuery 为 CSS 类注册事件处理程序不起作用

javascript - 我如何在我的 JQuery 中应用这个 JSONP api?

javascript - getElementsByClassName 没有选择我所有的导航元素

html - Css 转换不适用于 mozilla