/    Sign up×
Community /Pin to ProfileBookmark

gap between footer

Hello,

I’m creating a simple two column layout and there is a white gap between the left column and the footer. There is also a gap between the right. I would love the height to go down to the footer on the page. I tried height: 100%; margin-bottom: 0px; and some other things that didn’t work.

If you can take a look at the code and see what I have to do that will be great.

[CODE]body {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 13px;
}

#wrapper {
margin: 0 auto;
width: 100%;
}

#content {
color: #333;

background-color: #b0ffa0;
padding-bottom: 20px;
margin-left: 250px;
padding: 10px;

}

#header {
color: #333;
width: 100%;
float: left;
background: #2c2c2c;
}

#header-text {

height: 70px;
font-size: 10px;

line-height: 10px;

float: left;

vertical-align: text-bottom;

color: #fff;
padding-left: 2px;

}

#header-ads {

padding-top: 5px;
width: 240px;
float: right;

}

#footer {

width: 100%;
clear: both;
color: #333;
background: #6B6659;
height: 25px;

}

#navigation {

float: left;
width: 100%;
color: #fff;
background: #000000;
height: 40px;

}

#leftcolumn {

float: left;
color: #333;

background-color: #ffffa0;
width: 250px;

}

#leftcolumn p {

padding: 5px;

}

[/CODE]

[CODE]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>CSS Portal – Layout Generator</title>
<link rel=”stylesheet” type=”text/css” href=”226969.css” />
</head>

<body>

<div id=”wrapper”>

<div id=”header”>
<div id=”header-text”><br />
<h1>Company name</h1>
<h2>text goes here…</h2>
</div>
<div id=”header-ads”>

</div>
</div>
<div id=”navigation”>

<p>This is the Navigation</p>

</div>

<div id=”leftcolumn”>

<p>Left Column</p>

</div>

<div id=”content”>

<p>Sed placerat accumsan ligula. Aliquam felis magna, congue quis, tempus eu, aliquam vitae, ante. Cras neque justo, ultrices at, rhoncus a, facilisis eget, nisl. Quisque vitae pede. Nam et augue. Sed a elit. Ut vel massa. Suspendisse nibh pede, ultrices vitae, ultrices nec, mollis non, nibh. In sit amet pede quis leo vulputate hendrerit. Cras laoreet leo et justo auctor condimentum. Integer id enim. Suspendisse egestas, dui ac egestas mollis, libero orci hendrerit lacus, et malesuada lorem neque ac libero. Morbi tempor pulvinar pede. Donec vel elit. </p>

</div>

<div id=”footer”>

<p>This is the Footer</p>

</div>

</div>

</body>
</html>[/CODE]

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@ecrossauthorDec 21.2011 — This page seems to explain the situation I am having.

http://codegrad.hub.ph/fixed-width-two-column-css-layout/

The leftcolumn and the content areas are the ones that need to stretch vertically to accommodate more content. There is a gap between these sections and the footer. Should I create 1 pixel image and set a background to these columns or is there a better method?
Copy linkTweet thisAlerts:
@3NexDec 31.2011 — That's just the default value from your browser. The browser implies margins and paddings for some elements, just like it implies blue color and underlined text for links every time you don't specify any.

You say you tried [FONT="Courier New"]margin-bottom:0[/FONT], but you didn't try [FONT="Courier New"]margin-top:0[/FONT] on the footer, did you? Also, if you put [FONT="Courier New"]margin-bottom:0[/FONT] on the left column, the right column will still push the footer, did you take that into consideration?

Anyway, this, and many more problems you will have in life, are resolved with what's commonly called a CSS Reset. In your case, a simple line of [FONT="Courier New"]* { margin:0; }[/FONT] will take care of the problem. But be sure you add it to the beginning of your CSS file, not the end.
Copy linkTweet thisAlerts:
@hamburglarDec 31.2011 — Hey,

I looked at the code and upon inspection, there is a 13px margin for the paragraph tag of the footer.

These are the results I see in FF, Chrome and safari.

[code=html]

#footer p{
margin: 0px;
}
[/code]


Conversely if you want to keep that 13px space around the footer, then add it as a padding to the footer.
[code=html]
#footer{
padding: 13px;
}

#footer p{
margin: 0px;
}
[/code]


Let me know if this helps.

Regards,

H
Copy linkTweet thisAlerts:
@ecrossauthorJan 05.2012 — The css reset was not what I wanted as it set all margins to 0 making the page full width of the browser window. However, it did correct the spacing area between the content and the footer area but still left a gap in the left navigation. I did mess with the margin-top: 0 and margin-bottom 0.

Setting the paragraph tag in the footer in the first set of code tags hamburgular posted was more what I was after but it still left a gap in the left navigation.

Tested in IE and Firefox screen shot attached.
Copy linkTweet thisAlerts:
@hamburglarJan 05.2012 — Hey,

The 100% height problem happens too often. I always run into it and have never come across a legit solution.

The problem is that the div leftcolumn will take 100% height of the parent div or element. In this case that div element could be a container that has both left column and right column in it. However, the container in itself will require a height so the child can take % of the height.

The only way I have been able to resolve this issue is by using min-height. It has not been a 100% effective for dynamic websites but if the bg color is the same as the body, then it should give it the "effect" of 100% height.

I hope this helps.
Copy linkTweet thisAlerts:
@3NexJan 05.2012 — The css reset was not what I wanted as it set all margins to 0 making the page full width[/QUOTE]

No, the CSS reset is exactly what everybody wants, they just don't know it until they find a perfect problem. Just trust me on this one and start using it. The whole point is to set all the margins to zero (or, to eliminate all default values, because defaults are different on different browsers and that's always a bad thing) and then set all the margins to whatever you need after that (that's why CSS reset always goes on top). So, in your case, you'd want to set some kind of padding to body.

If you stick to doing this job in the future, one day you'll see i'm right. Margins aren't the only thing that need to be reset, you may want to google some CSS resets out there, people do different stuff. I think normalize.css is by far the most popular one, even used by html5boilerplate.

Altho personally, i just wrote my own, works fine so far..
×

Success!

Help @ecross spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...