I am trying to create a head area that is 100px in height and spans 100% in width. I need 2 columns with the left one being 250px wide and 100% in height down to the footer. The right column should be 100% of the remaining page width and 100% in height to the footer. The footer should be at the bottom of the page and 100px in height and 100% in width. Even if there is no content in the 2 columns, I need them to stretch down to the footer and have the footer visible without scrolling down to it.
Here is what I have so far.
<div id="top"><p>Lorem ipsum dolor sit amet</p></div>
<div id="left"><p>Lorem ipsum dolor sit amet</p></div>
<div id="right"><p>Lorem ipsum dolor sit amet</p></div>
<div id="bot"><p>Lorem ipsum dolor sit amet</p></div>
body, html {
height: 100%;
}
body {
margin: 0px;
}
p {
margin: 0px;
}
#top {
height: 100px;
background-color: #F4F4F4;
}
#left {
width: 250px;
height: 100%;
background-color: #878787;
float: left;
margin-bottom: -100px;
}
#right {
background-color: #323232;
height: 100%;
margin-bottom: -100px;
}
#bot {
clear: right;
height: 100px;
background-color: #DCDCDC;
margin-top: -100px;
z-index: 100;
position: relative;
}
Here is another example with a table
<table height="100%" width="100%" cellspacing="0" cellpadding="0" border="0" class="" id="">
<tr>
<td colspan="2" style="background-color: powderblue; height: 100px;">Header</td>
</tr>
<tr>
<td style="background-color: gray; width: 350px;">Left Col</td>
<td style="background-color: DarkSeaGreen">Right Col</td>
</tr>
<tr>
<td colspan="2" style="background-color: tomato; height: 100px;">Footer</td>
</tr>
</table>
To merge table columns in HTML use the colspan attribute in <td> tag. With this, merge cells with each other. For example, if your table is having 4 rows and 4 columns, then with colspan attribute, you can easily merge 2 or even 3 of the table cells.
On the Layout tab, click Columns, then click the layout you want. To apply columns to only part of your document, with your cursor, select the text that you want to format. On the Layout tab, click Columns, then click More Columns. Click Selected text from the Apply to box.
Here is a simple CSS-grid solution (I used 50px
instead of 100px
so we can see it in the reduced snippet)
html {
height: 100%;
}
p {
margin: 0px;
}
body {
min-height:100%;
margin:0;
display:grid;
grid-template-rows:50px 1fr 50px;
grid-template-columns:250px 1fr;
grid-template-areas:
"top top"
"left right"
"bot bot";
}
#top {
grid-area:top;
background: linear-gradient(#F4F4F4,blue);
}
#left {
grid-area:left;
background: linear-gradient(#878787,red);
}
#right {
grid-area:right;
background: linear-gradient(#323232,green);
}
#bot {
grid-area:bot;
background: linear-gradient(#DCDCDC,purple);
}
<div id="top"><p>Lorem ipsum dolor sit amet</p></div>
<div id="left"><p>Lorem ipsum dolor sit amet</p></div>
<div id="right"><p>Lorem ipsum dolor sit amet</p></div>
<div id="bot"><p>Lorem ipsum dolor sit amet</p></div>
And here is with flexbox:
body, html {
height: 100%;
}
p {
margin: 0px;
}
body {
margin:0;
display:flex;
flex-wrap:wrap;
}
#top,#bot {
height:50px;
width:100%;
background: linear-gradient(#F4F4F4,blue);
}
#left {
width:250px;
min-height:calc(100% - 2 * 50px);
background: linear-gradient(#878787,red);
}
#right {
flex:1;
min-height:calc(100% - 2 * 50px);
background: linear-gradient(#323232,green);
}
<div id="top"><p>Lorem ipsum dolor sit amet</p></div>
<div id="left"><p>Lorem ipsum dolor sit amet</p></div>
<div id="right"><p>Lorem ipsum dolor sit amet</p></div>
<div id="bot"><p>Lorem ipsum dolor sit amet</p></div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With