Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8313181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:24:21+00:00 2026-06-08T20:24:21+00:00

I made this: HTML: <body> <div id=header > </div> <div id=main > </div> <div

  • 0

I made this:

HTML:

<body>
<div id="header" >
</div>
<div id="main" >
</div>
<div id="footer" >
</div>
</body>

CSS:

body
{
    margin:0px;
}
#header
{
    width:100%;
    background-color:black;
    height:60px;
}
#main
{
    width:300px;
    border:1px dotted black;
    margin:0 auto;
}
#footer
{
    width:100%;
    background-color:black;
    height:40px;
    position:absolute;
    bottom:0px;
}

http://jsfiddle.net/VpwQQ/2/

But as you can see, the main div doesn’t have a height.

Then I replaced my css by that:

body
{
    margin:0px;
}
#header
{
    width:100%;
    background-color:black;
    height:60px;
}
#main
{
    width:300px;
    border:1px dotted black;
    position:absolute;
    margin:0 auto;
    bottom:60px;
    top:80px;
}
#footer
{
    width:100%;
    background-color:black;
    height:40px;
    position:absolute;
    bottom:0px;
}

http://jsfiddle.net/VpwQQ/1/

But then, the horizontal center doesn’t work.

How can I do this design (div centered and that takes all the page in height between the header and footer with a 20 px magin) ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:24:23+00:00Added an answer on June 8, 2026 at 8:24 pm

    I’m not sure what you’re trying to do, but I’ll give my explaination of what’s going to happen with your code:

    Your #main div doesn’t have a height because it doesn’t have a height CSS property, nor does it have any content.

    You should add either a height: 100px or just add some content and you will see it gets a height.

    The reason why I ask what you want to do is because you’re not very clear as to what you want your final product to look like.

    You’re going to have another problem with the footer. If you use position absolute it sticks to the bottom at the moment. Set the height of the #main div to something ridiculously high and you’ll see that when you have to scroll down the page the footer stays where it is. See http://jsfiddle.net/VpwQQ/3/

    You should use position: fixed but this will keep it on the bottom of the WINDOW and not the DOCUMENT. So then you get into the problem of having to use Javascript in order to measure the document height and setting positions appropriately. Not sure what you’re trying to do, but if you’re just trying to lay out a website then use standard relative positioning to push the footer down naturally below the #main div.

    Edit:

    See http://jsfiddle.net/VpwQQ/4/ if you’re just trying to set up a normal website layout.

    If you want the footer to “stick” to the bottom of the page all the time then you will need to use position: fixed but I don’t think this works across all browsers. See http://jsfiddle.net/VpwQQ/6/

    Lastly, to get both footer and header to “stick” see http://jsfiddle.net/VpwQQ/8/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made this Greasemonkey script: var maxpi = 250; var p1 = /html/body/div/div[2]/div/div[2]/table[2]/tbody/tr[1]/td[11]; var
I made a countdown timer and coded this in with HTML and CSS, but
So I made this super stripped down version of a html css jquery navigation
Take this trivial example and open it: <html> <body style=background-image:url(http://upload.wikimedia.org/wikipedia/commons/2/21/Mandel_zoom_00_mandelbrot_set.jpg);background-repeat: no-repeat; background-position: top center;>
I saw this HTML minifier in Ajaxian and it made me wonder if its
I have made this webpage, you can check it out here http://www.bettingtowin.net/webcam.html I have
The html of this script is made with list items http://www.jeremymartin.name/projects.php?project=kwicks Where can I
Made this nice little loop for hiding and showing div's, works as a charm
<!DOCTYPE html> <html> <head> <title>Title</title> <meta http-equiv=content-type content=text/html; charset=utf-8> <style type=text/css> body { background:
I want to change the background color of the DIV depending on some true/false

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.