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 CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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 class="wrapper">
  <div class="main">
    <h1>Dynamic Flag</h1>
    <span class="flag-icon"></span>
    <small><span class="dynamic-text"></span></small>
    <h3>Top 3</h3>
    <span class="flag-icon first"></span>
    <span class="flag-icon second"></span>
    <small>South Korea</small>
    <span class="flag-icon third"></span>
              $countries: algeria argentina australia belgium bosnia brazil cameroon chile columbia costa_rica croatia ecuador england france germany ghana greece holland honduras iran italy ivory_coast japan mexico nigeria portugal russia south_korea spain switzerland united_states uruguay;

@mixin flag($chosen-country, $height) {
  $width: floor($height / 0.66);
  $newHeight: $width * 0.66;
  $spriteHeight: $width * 0.7;

  width: $width;
  height: $newHeight;

  @each $country in $countries {
    $i: index($countries, $country);
    $background-position: -($spriteHeight * ($i - 1));

    @if $chosen-country == $country {
      background-position: 0 $background-position;
    @else if $chosen-country == "all" {
      &.#{$country} {
        background-position: 0 $background-position;

.flag-icon {
  background: url('https://matthewshields.co.uk/wordpress/wp-content/themes/me/img/flag-sprite.svg');
  background-repeat: no-repeat;
  background-size: 100% auto;
  display: inline-block;

.main .flag-icon {
  @include flag(all, 275px);

aside .first {
  @include flag(australia, 80px);

aside .second {
  @include flag(south_korea, 80px);

aside .third { 
  @include flag(honduras, 80px); 


body {
  background: #f1f1f1;
  text-align: center;

.wrapper { 
  width: 620px;
  margin: 0 auto; 

.main {
  width: 440px;
  float: left;
  background: #ccc;

aside {
  width: 150px;
  float: right;
  background: #aaa;

small {
  margin-bottom: 10px;
  display: block;
    var classes = ["algeria", "argentina", "australia", "belgium", "bosnia", "brazil", "cameroon", "chile", "columbia", "costa_rica", "croatia", "ecuador", "england", "france", "germany", "ghana", "greece", "holland", "honduras", "iran", "italy", "ivory_coast", "japan", "mexico", "nigeria", "portugal", "russia", "south_korea", "spain", "switzerland", "united_states", "uruguay"];

    $(".main .flag-icon").each(function(){
        var random = classes[~~(Math.random()*classes.length)];
        $('.main .flag-icon').addClass(random);
Loading ..................