Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There are a few problems which you might want to resolve in order to fix this. The first is that your HTML is ambiguous / poorly formed:</p> <pre><code>&lt;div class="out"&gt;&lt;div class="left"&gt; &lt;/div&gt; &lt;div class="right"&gt;&lt;/div&gt; </code></pre> <p>My assumption is that what you really mean is:</p> <pre><code>&lt;div class="out"&gt; &lt;div class="left"&gt;&lt;/div&gt; &lt;div class="right"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>(You were missing a closing <code>&lt;/div&gt;</code>)</p> <p>With this fixed, the easiest solution is actually to pull the shadow <em>out</em> of the underlying tag (the <code>.out</code> <code>div</code>), and instead create the shadow as an <em>overlay</em>.</p> <p>Example:</p> <pre><code>&lt;div class="out"&gt; &lt;div class="left"&gt;&lt;/div&gt; &lt;div class="right"&gt;&lt;/div&gt; &lt;div class="shadow"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>With this done, you can easily place the <code>.left</code> and <code>.right</code> <code>&lt;div&gt;</code> elements where you want them, and then force the <code>.shadow</code> <code>div</code> to appear <em>on top</em>.</p> <p>Consider the following CSS (I also normalized your CSS some to reduce repetition):</p> <pre><code>.out, .shadow { height: 600px; width: 600px; } .out { background-color: AliceBlue; position: relative; } .shadow { background: transparent; -webkit-box-shadow: inset 0px 0px 5px 5px ; box-shadow: inset 0px 0px 5px 5px; position: absolute; top: 0; left: 0; } .left, .right { height: 100px; width: 100px; bottom: 0; position: absolute; } .left { background-color: green; left: 0; } .right { background-color: red; right: 0; } </code></pre> <p>Because the <code>.shadow</code> <code>div</code> appears <em>last</em>, you don't need any special <code>z-order</code> in order to get it to appear on-top.</p> <p><a href="http://cssdesk.com/JQpgs" rel="nofollow">Here is a working cssdesk</a> to demonstrate it in-action.</p> <p><strong>Edit:</strong></p> <p>As mentioned in the comments - the original question actually asks for only one of the two boxes to appear <em>under</em> the <code>box-shadow</code>. If you want one of them to appear <em>above</em> it, simply move that box's HTML tag so that it appears <em>after</em> the <code>.shadow</code> <code>&lt;div&gt;</code>, like this:</p> <pre><code>&lt;div class="out"&gt; &lt;div class="left"&gt;&lt;/div&gt; &lt;div class="shadow"&gt;&lt;/div&gt; &lt;div class="right"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>This will cause the <code>.right</code> box (the red one) to appear <em>above</em> the shadow, rather than below - without the need for any <code>z-index</code> nastiness.</p> <p>I have updated the cssdesk example to show this version instead.</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