Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To answer your last question first, as long as you don't need to support any browsers that completely lack support for generated content (<a href="http://caniuse.com/#feat=css-gencontent" rel="nofollow">http://caniuse.com/#feat=css-gencontent</a>) then you shouldn't need to avoid it. However, since you note that this is a known bug, you should be <em>careful</em> about it.</p> <p>In this specific example, I can think of three different ways to work around the bug. Whether these are useful to you depends on your actual use case.</p> <ol> <li><p>Use <code>:after</code> instead of <code>:before</code> and remove positioning from the child <code>div</code>: <a href="http://jsfiddle.net/AjCPM/24/" rel="nofollow">http://jsfiddle.net/AjCPM/24/</a></p> <pre><code>#target { position: relative; width: 200px; height: 200px; z-index: 1; } #target&gt;div{ background: red; width: 200px; height: 200px; } #target:after { content: "after"; position: absolute; top: 0; left: 10%; width: 100%; height: 100%; background: cyan; z-index: 10; } </code></pre></li> <li><p>Add the after to the child <code>div</code> instead of the parent: <a href="http://jsfiddle.net/AjCPM/26/" rel="nofollow">http://jsfiddle.net/AjCPM/26/</a></p> <pre><code>#target { position: relative; width: 200px; height: 200px; z-index: 1; } #target&gt;div{ position: relative; background: red; width: 200px; height: 200px; z-index: 0; } #target&gt;div:before{ content: "after"; position: absolute; top: 0; left: 10%; width: 100%; height: 100%; background: cyan; z-index: 10; } </code></pre></li> <li><p>Use a wrapping element (usually because you already have one) to apply the base styling to: <a href="http://jsfiddle.net/AjCPM/29/" rel="nofollow">http://jsfiddle.net/AjCPM/29/</a></p> <pre><code> &lt;div id="target"&gt; &lt;div id="wrap"&gt; &lt;div&gt;div&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; #target { position: relative; width: 200px; height: 200px; z-index: 1; } #wrap&gt;div{ position: relative; background: red; width: 200px; height: 200px; z-index: 0; } #wrap&gt;div:before{ content: "after"; position: absolute; top: 0; left: 10%; width: 100%; height: 100%; background: cyan; z-index: 10; } </code></pre></li> </ol> <p>Basically, when faced with a difference in interpretation between browsers like this, your best bet is to try to rearrange your approach to find something that works cross-browser.</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. 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