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

  • Home
  • SEARCH
  • 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 143739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:08:34+00:00 2026-05-11T08:08:34+00:00

I want a centered header DIV and inside it the following absolutely positioned DIVs:

  • 0

I want a centered header DIV and inside it the following absolutely positioned DIVs:

  • logo
  • menu
  • line
  • title

But my HTML/CSS has two problems:

  • for some reason the page is now wider (see bottom scroll bar)
  • If my title is longer, I want it to be right-aligned of course

What I really want is a centered DIV and inside that I want to position DIVs absolutely within their centered parent (but not absolute since they wouldn’t be centered). Is this possible?

How would you accomplish this layout?

alt text http://tanguay.info/web/external/centeredLayoutProblem.png

<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'> <html> <head>  <style type='text/css'>     #headerArea {         background-color: yellow;         margin: 0px auto;         width: 760px;         height: 150px;     }      #logo {         position: relative;         top: 20px;         left: 20px;         background-color: orange;         text-align: center;         font-size: 32pt;         width: 150px;         padding: 10px;         z-index: 10;     }      #menu {         position: relative;         top: -52px;         right: -480px;         background-color: tomato;         text-align: center;         font-size: 14pt;         width: 240px;         padding: 10px;     }      #title {         position: relative;         top: -35px;         right: -620px;         font-style: italic;         font-size: 14pt;     }      #line {         position: relative;         top: -60px;         border-bottom: 1px solid blue;         margin: 0 20px;     } </style>  </head>  <body>     <div id='headerArea'>         <div id='logo'>LOGO</div>         <div id='menu'>One&nbsp;&nbsp;Two&nbsp;&nbsp;Three&nbsp;&nbsp;Four&nbsp;&nbsp;Five</div>         <div id='title'>This is the Title a Bit Longer</div>         <div id='line'></div>     </div> </body> </html> 
  • 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. 2026-05-11T08:08:35+00:00Added an answer on May 11, 2026 at 8:08 am

    Make your #headerArea div position:relative. Then, for all your inner divs, you can position:absolute in relation to #headerArea.

    Like so:

    <style type='text/css'>     #headerArea {         position:relative;         background-color: yellow;         margin: 0px auto;         width: 760px;         height: 150px;     }      #logo {         position: absolute;         top: 20px;         left: 20px;         background-color: orange;         text-align: center;         font-size: 32pt;         width: 150px;         padding: 10px;         z-index: 10;     }      #menu {         position: absolute;         top: 20px;         left: 480px;         background-color: tomato;         text-align: center;         font-size: 14pt;         width: 240px;         padding: 10px;     }      #title {         position: absolute;         top: 80px;         left: 20px;     width: 720px;     text-align: right;         font-style: italic;         font-size: 14pt;     }      #line {         position: absolute; width: 720px;  height: 1px;         top: 70px;         border-bottom: 1px solid blue;         margin: 0 20px;     }  </style> 

    You should use the ‘left’ property instead of ‘right’ since ‘right’ doesn’t work in ie6.

    The ‘left’ and ‘top’ values I’ve put in may be a little off, but you can tweak to get what you want.

    EDIT:

    I’ve corrected the pixel values, and added a width to your line div, and a height since IE defaults all divs to one text line high.

    Also, your title div should be full width with text-align right so that the title will expand to the left instead of the right.

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

Sidebar

Related Questions

page I'm working with: http://jsbin.com/abewe4 I want the slogan div centered inside col3 div
I want to reference a COM DLL in a .NET project, but I also
I want to log onto Stack Overflow using OpenID, but I thought I'd set
So I have a div in my body that's a percentage width, and inside
This shouldn't be hard...I have a menu and some content wrapped in a centered,
I want the text of the ListBox to be centered, is that possible?
I want a 3*3 grid with an ImageButton centered in each cell I've done
I have data that is mostly centered in a small range (1-10) but there
I want to get the header of a selected tab-item of a tab-control and
Want to know what the stackoverflow community feels about the various free and non-free

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.