How to bring Footer to bottom back?

88 Views Asked by At

I was trying to draw a simple Blogspot page with HTML and CSS. I have designed some. Now I am stuck. I have a code:

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>

This code is not letting the footer at the bottom. Footer is with the sidebar.

I want footer at the bottom of the container as shown in below image https://i.stack.imgur.com/IREuq.jpg

What changes should I make in CSS or HTML?

Thank you.

2

There are 2 best solutions below

2
cobrius On

You put your "footer" in a div. you should use the html tag .

So take off the < div class="footer" > thing and then go after the < /body > tag and write:

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

put the <div> like this before <div class="footer">.

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

and add css code for this segment:

.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>