Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I see no need for "z-index"es or "position: absolute" in your code at all -- unless you have other complications that you have not revealed to us.</p> <p>To center the background on the DIV class="main":</p> <pre><code>body{margin:0;padding:20px 0;} .main{background:transparent url(bg1.jpg) no-repeat center top;} .content{border:#000 thin solid;width:960px;margin-left:auto;margin-right:auto;background-color:#000;opacity: 0.5;filter:alpha(opacity=50);-moz-opacity: 0.5;} </code></pre> <p>The "center top" places the center-top of the background image on the center-top of the element it's applied to. You may want to apply a</p> <pre><code>min-width:1024px;_width:1024px; </code></pre> <p>to the same element -- to prevent a narrower window from hiding the edges (this will change how the element is rendered if the "viewport" is narrower than the background's dimensions).</p> <p>The only thing your pre-modified code it can do that my modified code can't:</p> <ul> <li>Crop the background image (if it is not natively 1024px x 768px) by using the css "width" and "height" properties</li> <li>If the class="main" element already has a background image set, most browsers don't support the CSS3 required to stack multiple backgrounds on the same element</li> </ul> <p>Some of what was stated about "z-indexing" and the "position" property above was correct but failed to mention: you've taken your class="content" element out of "the flow". The ancestor elements won't grow when the content of class="content" element grows. This is an important and fundamental difference between "z-index"ed elements and elements that remain "in the flow".</p> <p>Other side notes:</p> <ul> <li>elements with the same z-index are stacked according to their order in the HTML (later in the HTML means they are drawn above on the screen)</li> <li>"z-index"ing requires "position: (absolute|relative)", "z-index: (valid value)", and IIRC "(top|left|bottom|right): (valid value)" to take the element "out of the flow"</li> </ul>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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