cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div></div>

<a href="//codepen.io/jakob-e/pen/doMoML" target="_blank">Updated version ➜</a>
<pre>
//  <strong>SCSS</strong>
// --------------------------------------------
//
//  Function to replace characters in a string
//
@function str-replace($string, $search, $replace: '') {
  $index: str-index($string, $search); 
  @if $index { 
    @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); 
  }
  @return $string; 
}


// --------------------------------------------
//
//  Function to create an optimized svg url
//  (may need a few extra replacements)
//
@function svg-url($svg){
  $svg: str-replace($svg,'"','\'');
  $svg: str-replace($svg,'&lt;','%3C');
  $svg: str-replace($svg,'&gt;','%3E');
  $svg: str-replace($svg,'&','%26');
  $svg: str-replace($svg,'#','%23');
  @return url("data:image/svg+xml;charset=utf8,#{$svg}");   
}


// --------------------------------------------
// 
//  Use it :-)
//
div {
    background-image : svg-url('&lt;svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"&gt;&lt;path d="M224 387.814V512L32 320l192-192v126.912C447.375 260.152 437.794 103.016 380.93 0 521.287 151.707 491.48 394.785 224 387.814z"/&gt;&lt;/svg&gt;');
    background-repeat: no-repeat;
    background-size  : contain;
    
    width:30%;
    padding-bottom:30%;
    margin:0 auto;
    
}

</pre>
            
          
!
            
              //
//  Function to replace characters in a string
//
@function str-replace($string, $search, $replace: '') {
    $index: str-index($string, $search); 
    @if $index { @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); }
    @return $string; 
}

//
//  Function to create an optimized svg url
//  (may need a few extra replacements)
//
@function svg-url($svg){
    $svg: str-replace($svg,'"','\'');
    $svg: str-replace($svg,'<','%3C');
    $svg: str-replace($svg,'>','%3E');
    $svg: str-replace($svg,'&','%26');
    $svg: str-replace($svg,'#','%23');
    @return url("data:image/svg+xml;charset=utf8,#{$svg}");   
}


//
//  Use it :-)
//
div {
    background-image : svg-url('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M224 387.814V512L32 320l192-192v126.912C447.375 260.152 437.794 103.016 380.93 0 521.287 151.707 491.48 394.785 224 387.814z"/></svg>');
    background-repeat: no-repeat;
    background-size  : contain;
    
    width:30%;
    padding-bottom:30%;
    margin:0 auto;
    
}



a { display: inline-block; background:tomato; text-decoration:none; color:white; margin:20px; border-radius:5px;
font:18px sans-serif; padding:10px;}


//
pre { font:11px monospace; padding:20px; background:whitesmoke; white-space:pre-wrap;border:1px solid #ccc; border-radius:7px;margin:20px;}

            
          
!
999px
Loading ..................

Console