Note that there are some explanatory texts on larger screens.

plurals
  1. POIs this the way to do absolute/relative/static CSS DIVs?
    primarykey
    data
    text
    <p>I want a centered header DIV and inside it the following absolutely positioned DIVs:</p> <ul> <li>logo</li> <li>menu</li> <li>line</li> <li>title</li> </ul> <p>But my HTML/CSS has two problems:</p> <ul> <li>for some reason the page is now wider (see bottom scroll bar)</li> <li>If my title is longer, I want it to be right-aligned of course</li> </ul> <p>What I really want is a centered DIV and inside that I want to position DIVs <em>absolutely within their centered parent</em> (but not absolute since they wouldn't be centered). Is this possible?</p> <p>How would you accomplish this layout?</p> <p><a href="http://tanguay.info/web/external/centeredLayoutProblem.png" rel="nofollow noreferrer">alt text http://tanguay.info/web/external/centeredLayoutProblem.png</a></p> <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; &lt;html&gt; &lt;head&gt; &lt;style type="text/css"&gt; #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; } &lt;/style&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="headerArea"&gt; &lt;div id="logo"&gt;LOGO&lt;/div&gt; &lt;div id="menu"&gt;One&amp;nbsp;&amp;nbsp;Two&amp;nbsp;&amp;nbsp;Three&amp;nbsp;&amp;nbsp;Four&amp;nbsp;&amp;nbsp;Five&lt;/div&gt; &lt;div id="title"&gt;This is the Title a Bit Longer&lt;/div&gt; &lt;div id="line"&gt;&lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload