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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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

              
                <center>
  <h1>Maritime Signal Flags Translator</h1>
  <hr/>
<input type="text" id="message" value="Happy Sailing">
<button onclick="convert();">Submit</button>
</center>
<hr/>
<div id="output">
  
</div>  
  
              
            
!

CSS

              
                @white: rgb(255,255,255);
@blue: rgb(25,78,156);
@yellow: rgb(251,209,27);
@red: rgb(205,19,43);
@black: rgb(0,0,0);
@flagSize: 4em;

body {
  background-color: #ccc;
  margin: 1em;
  font-size: 20px;
  font-family: arial;
}

INPUT, BUTTON {
  font-size: 20px;
  padding: 6px;
}

H1 {
  color: @blue;
   margin-bottom: 0px;
}

.flag {
  position: relative;
  float: left;
  width: @flagSize;
  height: @flagSize;
  margin: @flagSize/5;
  background-color: #fff;
  -webkit-box-sizing: border-box;
  -webkit-filter: drop-shadow(@flagSize/20 @flagSize/20 @flagSize/10 rgba(0,0,0,0.3)); 
  -webkit-transition: -webkit-transform 0.3s, background-color 0.7s;
  -webkit-transition-timing-function: cubic-bezier(.76,.13,.19,1.44);
  -webkit-transform-style: preserve-3d;
}
.flag:hover {
  transform: scale(1.5,1.5);
}

.flagA {
  background: transparent;
  border-top: @flagSize/2 solid @blue;
  border-right: @flagSize/3 solid transparent;
  border-bottom: @flagSize/2 solid @blue;
}
.flagA:before {
  content: "";
  position: absolute;
  top: -@flagSize/2;
  left: 0;
  height: @flagSize;
  width: @flagSize/2;
  background-color: white;
  z-index: 5;
}
.flagB {
  background: transparent;
  border-top: @flagSize/2 solid @red;
  border-right: @flagSize/3 solid transparent;
  border-bottom: @flagSize/2 solid @red;
}
.flagC {
  background: -webkit-linear-gradient(top, @blue 0%, @blue 20%, white 20%, white 40%, @red 40%, @red 60%, white 50%, white 80%, @blue 80%, @blue 100%);
}
.flagD {
  background: -webkit-linear-gradient(top, @yellow 0%, @yellow 25%, @blue 25%, @blue 75%, @yellow 75%, @yellow 100%);
}
.flagE {
  background: -webkit-linear-gradient(top, @blue 0%, @blue 50%, @red 50%, @red 100%);
}
.flagF {
  background-color: @red;
  background-image: linear-gradient(45deg, white 25%, transparent 25%, transparent 75%, white 75%), linear-gradient(-45deg, white 25%, transparent 25%, transparent 75%, white 75%);
}
.flagG {
  background: -webkit-linear-gradient(left, @yellow 0%, @yellow 16.66%, @blue 16.66%, @blue 33.33%, @yellow 33.33%, @yellow 50%, @blue 50%, @blue 66.66%, @yellow 66.66%, @yellow 83.33%, @blue 83.33%, @blue 100%);
}
.flagH {
  background: -webkit-linear-gradient(left, white 0%, white 50%, @red 50%, @red 100%);
}
.flagI {
  background-color: @yellow;
}
.flagI:after {
  content: "";
  background-color: @black;
  width: 50%;
  height: 50%;
  position: absolute;
  left: 25%;
  top: 25%;
  border-radius: 50%;
}
.flagJ {
    background: -webkit-linear-gradient(top, @blue 0%, @blue 33.33%, white 33.33%, white 66.66%, @blue 66.66%, @blue 100%);
}
.flagK {
  background: -webkit-linear-gradient(left, @yellow 0%, @yellow 50%, @blue 50%, @blue 100%);
}
.flagL {
  background-color: @black;
  background-image: linear-gradient(0, @yellow, @yellow), linear-gradient(0, @yellow, @yellow);
  background-size: 50% 50%;
  background-repeat: no-repeat;
  background-position: 0 0, 100% 100%;
}
.flagM {
  background-color: @blue;
  background-image: linear-gradient(45deg, transparent 42.93%, white 42.93%, white 57.07%, transparent 57.07%), linear-gradient(-45deg, transparent 42.93%, white 42.93%, white 57.07%, transparent 57.07%)
}
.flagN {
  background-image: linear-gradient(-45deg, @blue 25%, transparent 25%, transparent 75%, @blue 75%, @blue), 
  linear-gradient(-45deg, @blue 25%, transparent 25%, transparent 75%, @blue 75%, @blue);
  background-size: 50% 50%;
  background-position: 0 0, 50% 50%;
}
.flagO {
  background-image: linear-gradient(45deg, @yellow 50%, @red 50%)
}
.flagP {
  background-image: linear-gradient(0, @blue 33.33%, transparent 33.33%, transparent 66.66%, @blue 66.66%), linear-gradient(90deg, @blue 33.33%, transparent 33.33%, transparent 66.66%, @blue 66.66%);
}
.flagQ {
  background-color: @yellow;
}
.flagR {
  background-color: @red;
  background-image: linear-gradient(0, transparent 40%, @yellow 40%, @yellow 60%, transparent 60%), linear-gradient(90deg, transparent 40%, @yellow 40%, @yellow 60%, transparent 60%);
}
.flagS {
  background-color: @blue;
  background-image: linear-gradient(0, white 33.33%, transparent 33.33%, transparent 66.66%, white 66.66%), linear-gradient(90deg, white 33.33%, transparent 33.33%, transparent 66.66%, white 66.66%);
}
.flagT {
  background-image: linear-gradient(90deg, @red 33.33%, white 33.33%, white 66.66%, @blue 66.66%);
}
.flagU {
  background-image: linear-gradient(0, @red, @red), linear-gradient(0, @red, @red);
  background-size: 50% 50%;
  background-repeat: no-repeat;
  background-position: 0 0, 100% 100%;
}
.flagV {
  background-image: linear-gradient(45deg, transparent 42.93%, @red 42.93%, @red 57.07%, transparent 57.07%), linear-gradient(-45deg, transparent 42.93%, @red 42.93%, @red 57.07%, transparent 57.07%)
}
.flagW {
  background-image: linear-gradient(90deg, @blue 20%, white 20%, white 40%, transparent 40%, transparent 60%, white 60%, white 80%, @blue 80%), linear-gradient(0, @blue 20%, white 20%, white 40%, @red 40%, @red 60%, white 60%, white 80%, @blue 80%);
  background-size: 100% 60%, 100% 100%;
  background-repeat: no-repeat;
  background-position: 0 50%, 0 0;
}
.flagX {
  background-image: linear-gradient(0, transparent 40%, @blue 40%, @blue 60%, transparent 60%), linear-gradient(90deg, transparent 40%, @blue 40%, @blue 60%, transparent 60%);
}
.flagY {
  background: -webkit-linear-gradient(-45deg, @yellow 0%, @yellow 10%, @red 10%, @red 20%, @yellow 20%, @yellow 30%, @red 30%, @red 40%, @yellow 40%, @yellow 50%, @red 50%, @red 60%, @yellow 60%, @yellow 70%, @red 70%, @red 80%, @yellow 80%, @yellow 90%, @red 90%, @red 100%);
}
.flagZ {
  background-repeat: no-repeat;
  background-image: linear-gradient(45deg, @black 50%, @yellow 50%), linear-gradient(-45deg, @blue 50%, @yellow 50%), linear-gradient(-45deg, @red 50%, @black 50%), linear-gradient(45deg, @red 50%, @blue 50%);
  background-size: 50% 50%;
  background-position: 0% 0%, 100% 0%, 0% 100%, 100% 100%;
}

.flag0 { 
    @crossLegThickness: 6%;
    @nearCrossStart: 15% - @crossLegThickness/2;
    @nearCrossEnd: 15% + @crossLegThickness/2;
    @middleCrossStart: 50% - @crossLegThickness/2;
    @middleCrossEnd: 50% + @crossLegThickness/2;
    @farCrossStart: 85% - @crossLegThickness/2;
    @farCrossEnd: 85% + @crossLegThickness/2;
  
    background-repeat: no-repeat;
    background-color: white;
    background-position:
        top,
        left,
        0 0,
        0 0,
        0 0,
        0 0
        ;
    background-size:
        33% 100%,
        100% 33%,
        100% 100%,
        100% 100%,
        100% 100%,
        100% 100%
        ;
    background-image:
        linear-gradient(
            to bottom,
            @white 33%,
            transparent 33%,
            transparent 66%,
            @white 66%
        ),
        linear-gradient(
            to right,
            @white 33%,
            transparent 33%,
            transparent 66%,
            @white 66%
        ),
        linear-gradient(
            to right,
            @white 0,
            @white 5%,
            transparent 5%,
            transparent 25%,
            @white 25%,
            @white 40%,
            transparent 40%,
            transparent 60%,
            @white 60%,
            @white 75%,
            transparent 75%,
            transparent 95%,
            @white 95%
        ),
        linear-gradient(
            to bottom,
            @white 0,
            @white 5%,
            transparent 5%,
            transparent 25%,
            @white 25%,
            @white 40%,
            transparent 40%,
            transparent 60%,
            @white 60%,
            @white 75%,
            transparent 75%,
            transparent 95%,
            @white 95%
        ),
        linear-gradient(
            to right,
            transparent 0,
            transparent @nearCrossStart,
            @blue @nearCrossStart,
            @blue @nearCrossEnd,
            transparent @nearCrossEnd,
            transparent @middleCrossStart,
            @blue @middleCrossStart,
            @blue @middleCrossEnd,
            transparent @middleCrossEnd,
            transparent @farCrossStart,
            @blue @farCrossStart,
            @blue @farCrossEnd,
            transparent @farCrossEnd
        ),
        linear-gradient(
            to bottom,
            transparent 0,
            transparent @nearCrossStart,
            @blue @nearCrossStart,
            @blue @nearCrossEnd,
            transparent @nearCrossEnd,
            transparent @middleCrossStart,
            @blue @middleCrossStart,
            @blue @middleCrossEnd,
            transparent @middleCrossEnd,
            transparent @farCrossStart,
            @blue @farCrossStart,
            @blue @farCrossEnd,
            transparent @farCrossEnd
        );
}

.flag1 {
    background: -webkit-linear-gradient(top, @red 33.33%, @yellow 33.33%, @yellow 66.66%, @red 66.66%);
}
.flag2 {
    background: -webkit-linear-gradient(top, @yellow 33.33%, @red 33.33%, @red 66.66%, @yellow 66.66%);
}
.flag3 {
    background: -webkit-linear-gradient(top, @blue 33.33%, @red 33.33%, @red 66.66%, @blue 66.66%);
}
.flag4 {
  background-color: @red;
  background-image: linear-gradient(45deg, transparent 42.93%, white 42.93%, white 57.07%, transparent 57.07%), linear-gradient(-45deg, transparent 42.93%, white 42.93%, white 57.07%, transparent 57.07%)
}
.flag5 {
  background-color: @yellow;
  background-image: linear-gradient(45deg, transparent 42.93%, @blue 42.93%, @blue 57.07%, transparent 57.07%), linear-gradient(-45deg, transparent 42.93%, @blue 42.93%, @blue 57.07%, transparent 57.07%)
}
.flag6 {
  background-image: linear-gradient(-45deg, white 14.29%, @blue 14.29%, @blue 28.57%, white 28.57%, white 42.86%, @blue 42.86%, @blue 57.14%, white 57.14%, white 71.43%, @blue 71.43%, @blue 85.71%, white 85.71%)
}
.flag7 {
  background-image: linear-gradient(90deg, @red 33.33%, white 33.33%, white 66.66%, @red 66.66%);
}
.flag8 {
  background-image: linear-gradient(90deg, @yellow 33.33%, @blue 33.33%, @blue 66.66%, @yellow 66.66%);
}
.flag9 {
  background-image: linear-gradient(90deg, @blue 33.33%, white 33.33%, white 66.66%, @blue 66.66%);
}
              
            
!

JS

              
                //Maritime Signal Flags Translator by 101Computing.net
//www.101Computing.net/maritime-signal-flags-translator/

function convert() {
   var input = document.getElementById("message").value.toUpperCase();
   var output = document.getElementById("output");
   //Reset Output box
   output.innerHTML="";
  
   //Loop through each character
   for (var i = 0; i < input.length; i++) {
      var character = input.charAt(i);
      if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".indexOf(character)>=0) {
         var flag = document.createElement("DIV");  
         flag.className="flag flag" + character;
         output.appendChild(flag); 
      }
   }
}

convert();
              
            
!
999px

Console