Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

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

              
                
%h1 Flags of the world in pure CSS

.flag--denmark
.flag--russia
.flag--ireland
.flag--iceland
.flag--switzerland
.flag--bulgaria
.flag--italy
.flag--norway
.flag--finland
.flag--germany
.flag--sweden
.flag--netherlands
.flag--belgium
.flag--poland
.flag--france
.flag--ukraine
.flag--romania
.flag--lithuania
.flag--austria
.flag--spain
.flag--hungary
.flag--estonia


              
            
!

CSS

              
                
// Common properties
$flag-width: 9em;
$flag-height: $flag-width*10/16;

// Three thirds flag
@function thirds($first, $second, $last, $or: 90deg){
  @return linear-gradient($or, $first 33.3%, $second 33.3%, $second 66.6%, $last 66.6%);
}

// Two halfs flag
@function halfs($first, $second, $or: -180deg){
  @return linear-gradient($or, $first 50%, $second 50%);
}

// Crossed flag, with or without detail
@function cross($back, $main, $detail: $back){
  @return linear-gradient(90deg, transparent 28%, $main 28%, $main 34%, transparent 34%),
    linear-gradient(transparent 42%, $detail 42%, $detail 46%, $main 46%, $main 58%, $detail 58%, $detail 62%, transparent 62%),
    linear-gradient(90deg, $back 25%, $detail 25%, $detail 28%, $main 28%, $main 34%, $detail 34%, $detail 37%, $back 37%);
}


body{
  background: #f2f2f2;
  text-align: center;
}

%flag{
  width: $flag-width;
  height: $flag-height;
  border: 1px solid #999;
  display: inline-block;
  margin: 2em;
  box-shadow: 1px 1px 1px #CCC;
  transition: all .5s;
  
  &::after{
    content: attr(class);
    line-height: $flag-height*2.5;
  }
  
  &:hover{
    transform: scale(1.5);
  }
}


//Exceptions (not functions)

.flag--spain{
  @extend %flag;
  background: linear-gradient(red 25%, yellow 25%, yellow 75%,  red 75%);
}


.flag--switzerland{
  @extend %flag;
  background: linear-gradient(red 20%, transparent 20%, transparent 80%, red 80%),
    linear-gradient(90deg, red 30%, transparent 30%, transparent 45%, white 45%, white 55%, transparent 55%, transparent 70%, red 70%),
    linear-gradient(red 42%, white 42%, white 58%, red 58%);
}




// Made with functions

.flag--ireland{
  @extend %flag;
  background: thirds(#00ae00, white, orange);
}

.flag--italy{
  @extend %flag;
  background: thirds(#00ae00, white, red);
}

.flag--belgium{
  @extend %flag;
  background: thirds(black, yellow, red);
}

.flag--france{
  @extend %flag;
  background: thirds(mediumblue, white, red);
}

.flag--romania{
  @extend %flag;
  background: thirds(mediumblue, yellow, red);
}

.flag--germany{
  @extend %flag;
  background: thirds(black, red, gold, -180deg);
}

.flag--russia{
  @extend %flag;
  background: thirds(white, mediumblue, red, -180deg);
}


.flag--bulgaria{
  @extend %flag;
  background: thirds(white, green, red, -180deg);
}


.flag--netherlands{
  @extend %flag;
  background: thirds(red, white, mediumblue, -180deg);
}

.flag--lithuania{
  @extend %flag;
  background: thirds(gold, green, red, -180deg);
}

.flag--austria{
  @extend %flag;
  background: thirds(red, white, red, -180deg);
}


.flag--hungary{
  @extend %flag;
  background: thirds(red, white, green, -180deg);
}

.flag--estonia{
  @extend %flag;
  background: thirds(royalblue, darken(royalblue, 30%), white, -180deg);
}


.flag--poland{
  @extend %flag;
  background: halfs(white, red);
}

.flag--ukraine{
  @extend %flag;
  background: halfs(royalblue, yellow);
}

.flag--denmark{
  @extend %flag;
  background: cross(red, white);
}


.flag--iceland{
  @extend %flag;
  background: cross(mediumblue, red, white);
}

.flag--norway{
  @extend %flag;
  background: cross(red, blue, white);
}

.flag--finland{
  @extend %flag;
  background: cross(white, blue, blue);
}


.flag--sweden{
  @extend %flag;
  background: cross(mediumblue, yellow, yellow);
}


              
            
!

JS

              
                
              
            
!
999px

Console