Skip to content

Instantly share code, notes, and snippets.

@AbhishekGhosh
Created July 2, 2013 05:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhishekGhosh/5906886 to your computer and use it in GitHub Desktop.
Save AbhishekGhosh/5906886 to your computer and use it in GitHub Desktop.
Base64 CSS
<!--PHP Part-->
<?php
$str = <<<EOS
<?xml version="1.0" ?>
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none">
<linearGradient id="grad-ucgg-generated" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#6356ff" stop-opacity="1"/>
<stop offset="100%" stop-color="#75b6ff" stop-opacity="1"/>
</linearGradient>
<rect x="0" y="0" width="1" height="1" fill="url(#grad-ucgg-generated)" />
</svg>
EOS;
$b64 = base64_encode($str);
?>
<!--CSS Objective-->
.element {
background:url(data:image/svg+xml;base64,<?php echo $b64 ?>);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment