如何使Footer倒退?

时间:2019-05-02 20:18:08

标签: html css blogger blogspot

我试图用HTML和CSS绘制一个简单的Blogspot页面。我设计了一些。现在我被困住了。我有一个代码:

body{
	background-color: #5e769b;
	font: 16px/28px, arial, sans-serif; 
}
.container{
	background-color: #edeff2;
	width: 790px;
	margin: auto;
}
.header{
	padding-bottom: 20px;
	background-color: #6191dd;
	text-align: center;
}
.article{
	padding: 20px;
	text-align: justify;
	background-color: #f9f9f9;
	box-sizing: border-box;
	width: 70%;
	float: left;
}
.sidebar {
	padding: 20px;
	text-align: justify;
	background-color: #f9f9f9;
	box-sizing: border-box;
	width: 30%;
	float: right;
}
.footer{
	padding: 10px;
	text-align: center;
	background-color: #6b4edb;
	box-sizing: border-box;
	width: 100%;
	color: #263959;
}
.footer,
a {
	text-decoration: none;
	color: #fff;
}
<div class="container">
	<div class="header">
		<h1>welcome</h1>
		<h2>test blog</h2>
	</div>
	<div class="article">
		<h2>Article</h2>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
	</div>
	<div class="sidebar">
		<h2>sidebar</h2>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
	</div>
	<div class="footer">
		<h4>CopyRight @ <a href="#">footer</a></h4>
	</div>
</div>

此代码不允许页脚位于底部。页脚位于侧边栏。

我要在容器底部放置页脚,如下图所示 https://i.imgur.com/PFuGq2I.jpg

我应该在CSS或HTML中进行哪些更改?

谢谢。

2 个答案:

答案 0 :(得分:0)

您将“页脚”放在div中。您应该使用html标记。

因此,脱下

的东西,然后在标签之后输入:

<footer class="footer">
    <h4>Copyright @ <a href="#">Footer</a></h4>
</footer>

答案 1 :(得分:0)

像这样在<div>之前放入<div class="footer">

<div class="footerToBottom"></div>

并为此段添加 css 代码:

.footerToBottom{
    clear:both;
    display:block;
    width:0 !important;
    height:0 !important;
    min-height:0 !important;
    min-width:0 !important;
    margin:0 !important;
    padding:0 !important;
    overflow:hidden
}

body{
	background-color: #5e769b;
	font: 16px/28px, arial, sans-serif; 
}
.container{
	background-color: #edeff2;
	width: 790px;
	margin: auto;
}
.header{
	padding-bottom: 20px;
	background-color: #6191dd;
	text-align: center;
}
.article{
	padding: 20px;
	text-align: justify;
	background-color: #f9f9f9;
	box-sizing: border-box;
	width: 70%;
	float: left;
}
.sidebar {
	padding: 20px;
	text-align: justify;
	background-color: #f9f9f9;
	box-sizing: border-box;
	width: 30%;
	float: right;
}
.footer{
	padding: 10px;
	text-align: center;
	background-color: #6b4edb;
	box-sizing: border-box;
	width: 100%;
	color: #263959;
}
.footer,
a {
	text-decoration: none;
	color: #fff;
}
.footerToBottom{
	clear:both;
	display:block;
	width:0 !important;
	height:0 !important;
	min-height:0 !important;
	min-width:0 !important;
	margin:0 !important;
	padding:0 !important;
	overflow:hidden
}
<div class="container">
	<div class="header">
		<h1>welcome</h1>
		<h2>test blog</h2>
	</div>
	<div class="article">
		<h2>Article</h2>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
	</div>
	<div class="sidebar">
		<h2>sidebar</h2>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
	</div>
	<div class="footerToBottom"></div>
	<div class="footer">
		<h4>CopyRight @ <a href="#">footer</a></h4>
	</div>
</div>