HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<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>
@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%);
}
//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();
Also see: Tab Triggers