Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can avoid extra markup by using :after CSS pseudo element. Thus, your final markup will look like:</p> <pre><code>&lt;ul&gt; &lt;li class="light"&gt; &lt;img src="http://farm3.static.flickr.com/2802/4253151258_7d12da9e1c_z.jpg" /&gt; &lt;/li&gt; &lt;li class="dark"&gt; &lt;img src="http://farm1.static.flickr.com/31/66005536_d1c5afca29_z.jpg?zz=1" /&gt; &lt;/li&gt; &lt;li class="light"&gt; &lt;img src="http://farm4.static.flickr.com/3574/3646151231_0c68f4f974_z.jpg" /&gt; &lt;/li&gt; &lt;li class="dark"&gt; &lt;img src="http://farm4.static.flickr.com/3432/3310214210_813d13c899_z.jpg" /&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p>And the altered CSS will be:</p> <pre><code>.dark:after, .light:after, .dark .after, .light .after { position: absolute; display: block; content: ''; top: 0; left: 0; height: 100%; width: 76px; background: transparent url(logo-white.png) no-repeat fixed 0 0; z-index: 5; } .dark:after, .dark .after { background-image: url(logo-black.png); } </code></pre> <p>Notice that there is <code>.after</code> class there. This is to make it work in IE&lt;8, which, sadly, requires to use an expression:</p> <pre><code>.dark, .light { behavior: expression( !this.before ? this.before = this.innerHTML = '&lt;div class="after"&gt;&lt;/div&gt;' + this.innerHTML : '' ); } </code></pre> <p>While using expressions is generally discouraged, this one shouldn't affect the performance too much, since it is fully evaluated only once, and when the element is created, the condition returns false.</p> <p>There is one pitfall, though. If IE8 works in IE8/IE8 mode, the pseudo-elements will be <em>under</em> the images, unless you set <em>negative</em> <code>z-index</code> for the latter, which isn't always acceptable.</p> <p>You can look at <a href="http://jsfiddle.net/McsEX/" rel="nofollow">working example here</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.
 

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