Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>IE9 currently lacks CSS3 gradient support. However, here is a nice workaround solution using PHP to return an SVG (vertical linear) gradient instead, which allows us to keep our design in our stylesheets.</p> <pre><code>&lt;?php $from_stop = isset($_GET['from']) ? $_GET['from'] : '000000'; $to_stop = isset($_GET['to']) ? $_GET['to'] : '000000'; header('Content-type: image/svg+xml; charset=utf-8'); echo '&lt;?xml version="1.0"?&gt; '; ?&gt; &lt;svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%"&gt; &lt;defs&gt; &lt;linearGradient id="linear-gradient" x1="0%" y1="0%" x2="0%" y2="100%"&gt; &lt;stop offset="0%" stop-color="#&lt;?php echo $from_stop; ?&gt;" stop-opacity="1"/&gt; &lt;stop offset="100%" stop-color="#&lt;?php echo $to_stop; ?&gt;" stop-opacity="1"/&gt; &lt;/linearGradient&gt; &lt;/defs&gt; &lt;rect width="100%" height="100%" fill="url(#linear-gradient)"/&gt; &lt;/svg&gt; </code></pre> <p>Simply upload it to your server and call the URL like so:</p> <pre><code>gradient.php?from=f00&amp;to=00f </code></pre> <p>This can be used in conjunction with your CSS3 gradients like this:</p> <pre><code>.my-color { background-color: #f00; background-image: url(gradient.php?from=f00&amp;to=00f); background-image: -webkit-gradient(linear, left top, left bottom, from(#f00), to(#00f)); background-image: -webkit-linear-gradient(top, #f00, #00f); background-image: -moz-linear-gradient(top, #f00, #00f); background-image: linear-gradient(top, #f00, #00f); } </code></pre> <p>If you need to target below IE9, you can still use the old proprietary 'filter' method:</p> <pre><code>.ie7 .my-color, .ie8 .my-color { filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr="#ff0000", endColorStr="#0000ff"); } </code></pre> <p>Of course you can amend the PHP code to add more stops on the gradient, or make it more sophisticated (radial gradients, transparency etc.) but this is great for those simple (vertical) linear gradients.</p>
    singulars
    1. This table or related slice is empty.
    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