Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>My personal favourite pseudo-selector is :target . </p> <p>Here is a little pure-CSS lightbox I created that relies solely on :target. The lightbox is called <a href="http://lightbocss.eggmaps.com/" rel="nofollow">LightBoCSS</a> (for obvious reasons). There is a demo on the main page, and a link to the github repository. Note that I haven't put any non-webkit transitions in there yet, so use a webkit browser for the best experience.</p> <h1>The HTML:</h1> <pre><code> &lt;div class="lightbox"&gt; &lt;!-- ===== Put the thumbnails in here ===== --&gt; &lt;div class="thumbnails"&gt; &lt;a href="#b1"&gt; &lt;img src="images/ScreenShot1thumb1.png"/&gt; &lt;/a&gt; &lt;a href="#b2"&gt; &lt;img src="images/ScreenShot2thumb2.png"/&gt; &lt;/a&gt; &lt;/div&gt; &lt;!-- ===== Put the big images in here ===== --&gt; &lt;div class="lightboximg"&gt; &lt;a id="b1" href="#"&gt; &lt;img src="images/ScreenShot1.jpg" alt="EggMaps iPhone Screenshot 1" /&gt; &lt;/a&gt; &lt;a id="b2" href="#"&gt; &lt;img src="images/ScreenShot2.jpg" alt="EggMaps iPhone Screenshot 2" /&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <h2>The Basic (distilled) CSS that makes it work:</h2> <p>The "top" property is changed when the "a" is the target.</p> <pre><code>/* Hide each large image */ .lightboximg &gt; a { /* the container for a large image */ top: -999em; } /* display the (large image container) anchor elem when it is the target */ .lightboximg &gt; a:target { top: 0px; } </code></pre> <h2>The Complete CSS:</h2> <pre><code>/* Note the :target pseudo-selector. */ /* Hide each large image */ .lightboximg &gt; a { /* the container for a large image */ display: block; min-height: 100%; width: 100%; position: absolute; /*top: -999em; for browsers that can't set top in percentages - see comment from xception below */ top: -101%; background-color: #222222; /* dark grey - for browsers that can't do rgba */ background-color: rgba(0,0,100,0.4); /* for browsers that can't set multiple backgrounds */ background: url(Fabric-14.png), rgba(0,0,100,0.4); opacity: 0; transition: top 1s ease-in-out, opacity 1s ease-in-out, z-index 0.5s ease-in-out; -webkit-transition: top 1s ease-in-out, opacity 1s ease-in-out, z-index 0.5s ease-in-out; z-index: -1; } /* display the (large image container) anchor elem when it is the target */ .lightboximg &gt; a:target { top: 0px; opacity: 1; transition: top 1s ease-in-out, opacity 1s ease-in-out, z-index 0.5s ease-in-out; -webkit-transition: top 1s ease-in-out, opacity 1s ease-in-out, z-index 0.5s ease-in-out; z-index: 1001; } /* style for the large images */ .lightboximg &gt; a img { /* centre the image */ display:block; margin: 0px auto; /* make it fit into the window */ max-width: 100%; } </code></pre>
    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.
 

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