Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can't reliably set <code>z-index</code> without setting <code>position</code> on your elements; the stacking is also relative to the elements' containers, so if everything is at root level the image with a negative <code>z-index</code> will disappear behind the page. (Personally, I try and avoid negative <code>z-index</code> values whenever possible.)</p> <pre><code>#boxes { position: relative; } #boxes img { border:1px solid; margin:4px 0 0 0px; padding:0; position: absolute; width: 359px; height: 218px; z-index: 1 ; -moz-border-radius-topright:5px; -moz-border-radius-topleft:5px; -moz-border-radius-bottomright:5px; -moz-border-radius-bottomleft:5px; -webkit-border-top-right-radius:5px; -webkit-border-top-left-radius:5px; -webkit-border-bottom-right-radius:5px; -webkit-border-bottom-left-radius:5px; } #boxes .box { width:370px; height:241px; float:left; background-image:url(../imgs/box_front.png); background-repeat:no-repeat; background-color:#FFF; margin:80px 30px 0 0; position: relative; z-index: 2; } </code></pre> <h1>EDIT:</h1> <p>The problem is that your HTML is structured so the red stripe is the background image of the container that you're loading the image into. As this also has a <code>background-color</code>, the image is being lost behind it.</p> <p>A better way of doing this would be to use HTML/CSS' natural document flow - i.e. the later the element appears in the HTML, the 'higher' it is in the natural z-index. This'll mean you don't have to specify <code>z-index</code> values, but you will need to add a presentational <code>div</code> to your code (unless you want to monkey around with <code>:after</code> pseudo-elements):</p> <p>Each grey box will need to look like this:</p> <pre><code>&lt;div class="grey box"&gt; &lt;h3&gt;&lt;a href="#"&gt;Stationary&lt;/a&gt;&lt;/h3&gt; &lt;a href="#" class="normal"&gt;&lt;span class="border"&gt;&amp;nbsp;&lt;/span&gt;&lt;img src="http://placekitten.com/g/361/220"&gt;&lt;div class="innerBox"&gt;&amp;nbsp;&lt;/div&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>... and your CSS will need to change. Remove the background from the <code>.box</code> styles, and add this to your CSS:</p> <pre><code>#boxes .innerBox { position: absolute; left: 0; top: 0; width:370px; height:241px; background-image:url(http://i754.photobucket.com/albums/xx182/rache_R/box_front_zps196242cf.png); background-repeat:no-repeat; } </code></pre> <p>You can then remove the z-index from <code>#boxes .box</code>, and because the <code>innerBox</code> div appears after the image in your markup, it will naturally appear higher than your image.</p> <p>If you can't add any extra HTML to your markup template, you could repurpose the <code>border</code> divs, which don't seem to be doing much:</p> <pre><code>#boxes .border { border:none; z-index:1; cursor:pointer; position: absolute; left: 0; top: 0; width:370px; height:241px; background-image:url(http://i754.photobucket.com/albums/xx182/rache_R/box_front_zps196242cf.png); background-repeat:no-repeat; } </code></pre> <p>You'll need to update your images too: </p> <pre><code>#boxes img { /* other declarations */ position: absolute; left: 4px; top: 0; /* other declarations */ } </code></pre> <p>... and make sure your <code>#boxes .box</code> style has <code>position: relative;</code> set.</p> <p>That should do you: <a href="http://jsfiddle.net/mr3Fq/4/" rel="nofollow">http://jsfiddle.net/mr3Fq/4/</a></p>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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