Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="wrapper">
  <p class="text-gradient">Simple Text Gradient Example</p>
   <div class="bar one">
		<p class="text">Black or White Text Colour Change</p>
  </div> 
  <div class="bar two">
		<p class="text">Dynamic Gradient Text Colour Change</p>
  </div> 
  <div class="bar three">
		<p class="text">Percentage Gradient</p>
  </div> 
   <div class="bar four">
		<p class="text">Percentage Gradient Animation</p>
  </div> 
</div>




              
            
!

CSS

              
                /* COLOR VARIABLES
============================================= */
$yellow: #ffec1a;
$orange: #ffa600;
$purple: #23034d;
$black: #000;
$white: #fff;
$grey: #e3e3e3;


/* LAYOUT
============================================= */

.wrapper {
  position: relative;
  overflow: hidden;
  width: 500px;
  margin: 0 auto;
}

.bar {
  border: solid 1px #e3e3e3;
  margin: 40px 30px;
  padding: 8px 0;
  height: 55px;
}

/* TEXT
============================================= */
.text {
  font-size: 22px;
  font-weight: bold;
  margin: 10px 0;
  text-align: center;
}

/* LISTS
============================================= */ 

$lista: ($purple),
        ($orange),
        ($yellow);

$listb: ($orange 0%),
        ($orange 50%),
        ($white 50%),
        ($white 100%);


/* MIXINS
============================================= */

@mixin gradient($direction, $list) { 
  background: $orange;
  background: -webkit-linear-gradient($direction, $list);
 
}


@mixin animation($bg-size, $time) { 
  background-size: $bg-size $bg-size;
  -webkit-animation: AnimationName $time ease infinite;

  @-webkit-keyframes AnimationName {
      0% {background-position:100% 0%}
      100% {background-position:0% 0%}
  }
  
}

/* FUNCTIONS
============================================= */

@function text-color($list){
   $text-list:();
   @each $color, $percentage in $list {   
    @if lightness($color) > 50% {
     $text-list:append($text-list, $black $percentage, comma);    
    } @else {
        $text-list:append($text-list, $white $percentage, comma);
     }        
	}
  @return $text-list;
} 


@function text-color2($list){
   $text-list:();
   @each $color in $list { 
     $text-list:append($text-list, invert($color), comma);    
	}
  @return $text-list;
} 


/* BARS
============================================= */

.text-gradient {
  width: 100%;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  color: $orange; // Fallback solid text colour for un-supported browsers
  background: -webkit-linear-gradient(left, $black, $orange);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent; 
}

.one {  
 @include gradient(left, $lista);
    .text {
   	@include gradient(left, text-color($lista));
     -webkit-background-clip: text;
     -webkit-text-fill-color: transparent;    
    }
}

.two {  
 @include gradient(left, $lista);
    .text {
   	@include gradient(left, text-color2($lista));
     -webkit-background-clip: text;
     -webkit-text-fill-color: transparent; 
    }
}

.three {  
	 @include gradient(left, $listb);
    .text {
   	@include gradient(left, text-color($listb));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent; 
  }
}

.four {  
 @include gradient(left, $listb);
 @include animation(200% , 10s);
    .text {
   	@include gradient(left, text-color($listb));
     @include animation(200% , 10s);
     -webkit-background-clip: text;
     -webkit-text-fill-color: transparent; 
    }
}
              
            
!

JS

              
                
              
            
!
999px

Console