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 8362989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:04:19+00:00 2026-06-09T12:04:19+00:00

I have a header, a sidebar, and a content div. The Header is docked

  • 0

I have a header, a sidebar, and a content div.

The Header is docked to the top and fixed there. The sidebar is fixed the to the left. Now I have 3/4 of the screen on the right free of space. I have a content div that I want to place there. It needs to be centered in that 3/4 space.

Here is my code for the sidebar and content div.

CSS:

html,body {
    height:100%;
}
#sidebar {
    float: left;
    width: 300px;
    background: #fff;
    background: rgba(225,225,225,0.2);
    height:100%;
}
#sidebarTop {
    height:100%;
    background-color: #eee;
    padding:20px 50px;
    border-bottom:0.15em solid rgb(229,229,229);
    background: rgba(225,225,225,0.25);
    box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
    -o-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
    -webkit-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0px 1px rgba(255,255,255,0.3), inset 0px 0px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset -10px 0px 0px rgba(0,0,0,0.3);
    -moz-box-shadow: 0 2px 6px rgba(0,0,0,0.5), inset 0 1px rgba(255,255,255,0.3), inset 0 10px rgba(255,255,255,0.2), inset 0 10px 20px rgba(255,255,255,0.25), inset 0 -15px 30px rgba(0,0,0,0.3);
}
#content {
    margin: 0 auto;
    display:block;
    width:400px;
    margin-top:100px;
    height:900px;
    background:#FFF;
    -webkit-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
    -moz-box-shadow:    0px 0px 30px rgba(255, 255, 255, 1);
    box-shadow:         0px 0px 30px rgba(255, 255, 255, 1);
}

Here is my HTML code for sidebar and content div.

<div id="sidebar">
    <div id="sidebarTop">
        ....
    </div>
</div>
<div id="content">
    TEST
</div>

The problem comes here. What happens is that instead of ignoring the sidebar and pushing the content div to 100px down (margin-top:100px), it brings the side-bar down to the same level too.

My goal is to center that div both vertically and horizontally in that 3/4 of screen space left after the sidebar and the header fill the rest.

Any help is much appreciated!

  • 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-09T12:04:21+00:00Added an answer on June 9, 2026 at 12:04 pm

    Add float:left; to #content.

    #content {
        margin: 0 auto;
        width:400px;
        margin-top:100px;
        height:900px;
        background:#FFF;
        -webkit-box-shadow: 0px 0px 30px rgba(255, 255, 255, 1);
        -moz-box-shadow:    0px 0px 30px rgba(255, 255, 255, 1);
        box-shadow:         0px 0px 30px rgba(255, 255, 255, 1);
    }
    

    should be:

    #content
    {
        margin:100px auto 0;
        width:400px;
        height:900px;
        background:#fff;
        -webkit-box-shadow:0 0 30px #fff;
        -moz-box-shadow:0 0 30px #fff;
        box-shadow:0 0 30px #fff;
        float:left;
    }
    

    Updated:

    CSS

    html,
    body
    {
        height:100%;
    }
    #sidebar
    {
        position:fixed;
        top:0;
        left:0;
        width:300px;
        height:100%;
        background-color:#758;
    }
    #content
    {
        margin-left:-50px;
        position:absolute;
        top:100px;
        left:50%;
        width:400px;
        height:900px;
        background:#758;
    }​
    

    HTML

    <div id="sidebar">
        "fixed" sidebar
    </div>
    <div id="content">
        "horizontally centered" content
    </div>​
    

    DEMO


    Update 2:

    CSS

    #wrapper
    {
        position:absolute;
        top:100px;
        left:300px;
        right:0;
        height:900px;
    }
    #content
    {
        margin:0 auto;
        width:400px;
        height:100%;
        background:#758;
    }
    

    HTML

    <div id="sidebar">
        "fixed" sidebar
    </div>
    <div id="wrapper">
        <div id="content">
            "horizontally centered" content
        </div>
    </div>​​​​​​​​​​
    

    DEMO 2

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

Sidebar

Related Questions

Say I have the following DIVs: <div id=top>Page header</div> <div id=main>Main content</div> <div id=sidebar>Sidebar
I have the following html structure: <div class=container> <div class=header></div> <div class=sidebar></div> <div class=content-loading></div>
In this html I basically have a sidebar-div and a page-div with the header,
I have a #sidebar (which starts below my #header div) and a #footer (around
I am usually using this code div#wrapper{width:900px; margin: 0 auto;} div#header{float:left; width: 900px;} div#sidebar{float:left;
I have a basic layout page template: --- layout: default --- <header class="sidebar"> {{
How to align the buttons bottom of the screen.In the layout i have header
I have a header file buildTree.h and a C file buildTree.c there is a
I have an issue with dynamically resizing the height of my sidebar div to
I have a sidebar #sidebar { float: left; position: relative; width: 200px; padding: 20px;

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.