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 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.
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.
If the stylesheet 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 CSS 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.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<!-- Cookie Font -->
<link href='http://fonts.googleapis.com/css?family=Cookie' rel='stylesheet' type='text/css'>
<div class="circle" id="bg">
<div class="text"> Happy Birthday AMP! </div>
<!-- <button type="button" onclick='getElementById("bg").style.backgroundColor = "#f69e54"'>Click to Change Colors </button>
-->
<!-- Words on Birthday Hat, Roman Numerals for 23-->
<div class="X1a"></div>
<div class="X1b"></div>
<div class="X2a"></div>
<div class="X2b"></div>
<div class="I1"></div>
<div class="I2"></div>
<!-- <div class="I3"></div> -->
<!-- Decor on the point of the Birthday Hat -->
<div class="dot"></div>
<div class="face">
<div class="nose"></div>
<div class="forehead-shine"></div>
<div class="l-eye">
<div class="l-lid"></div>
</div>
<div class="r-eye">
<div class="r-lid"></div>
</div>
<div class="l-brow"></div>
<div class="r-brow"></div>
<div class="nose"></div>
<div class="mouth"></div>
<div class="l-cheek"></div>
<div class="r-cheek"></div>
</div>
<!-- Outside the Face -->
<div class="hat">
<!-- styling for top and margin-top doesn't work, why?
<div class="X1"></div>
<div class="X2"></div>
<div class="I1"></div>
<div class="I2"></div> -->
</div>
<div class="neck">
<div class="neck-shadow"></div>
</div>
<div class="hair"></div>
<div class="body">
<div class="l-cover"></div>
</div>
<div class="r-body">
<div class="r-cover"></div>
</div>
<div class="l-hand"></div>
<div class="r-hand"></div>
</div>
body {
background-color: #62babd;
}
/* Find out how to move button that has position: relative */
button {
width: 150px;
height: 60px;
position: absolute;
right: -60%;
top: 20%;
color: white;
font-family: Courier;
background-color: #ea8c82;
border: 4px solid #fb556e;
}
.circle {
position: relative;
margin: auto;
width: 400px;
height: 400px;
border-radius: 50%;
background: linear-gradient(#f5be3b, #efc622); /* note - you can add three colors */
border: 10px solid white;
/* border-box: border;
box-shadow: inset 5px 5px 0px 25px #d6bf80; */
margin-top: 3%;
}
/* Search for ways to curve the text with JS only, CSS only, ... */
.text {
position: absolute;
top: 20%;
right: -90%;
font: 300 50px/0.8 'Cookie', Helvetica, sans-serif; /* REVIEW */
color: white;
text-shadow: 4px 4px 3px rgba(0,0,0,0.1); /* REVEIW */
}
.face {
position: absolute;
width: 120px;
height: 150px;
background-color: #dec3ae;
border-radius: 60px;
left: 35%;
top: 25%;
z-index: 4;
}
.nose {
position: absolute;
background-color: #c5a78d;
border-bottom-left-radius: 40px;
border-bottom-right-radius: 40px;
width: 15px;
height: 5px;
top: 62%;
left: 45%;
}
.forehead-shine {
position: absolute;
background-color: #f1f2ed;
width: 8%;
height: 10%;
border-radius: 30px;
transform: rotate(110deg);
-webkit-transform:rotate(110deg);
-ms-transform: rotate(110deg);
-os-transform: rotate(110deg);
right: 24%;
top: 12%;
}
.l-eye {
position: absolute;
background-color: #231d37;
width: 10%;
height: 6%;
border-radius: 50%;
transform: rotate(10deg);
-webkit-transform:rotate(10deg);
-ms-transform: rotate(10deg);
-os-transform: rotate(10deg);
top: 45%;
left: 25%;
}
.r-eye {
position: absolute;
background-color: #231d37;
width: 10%;
height: 6%;
border-radius: 50%;
transform: rotate(-10deg);
-webkit-transform:rotate(-10deg);
-ms-transform: rotate(-10deg);
-os-transform: rotate(-10deg);
top: 45%;
right: 25%;
}
.l-lid {
position: absolute;
background-color: #211a39;
width: 30%;
height: 250%;
transform: rotate(85deg);
-webkit-transform:rotate(85deg);
-ms-transform: rotate(85deg);
-os-transform: rotate(85deg);
top: -130%;
left: -20%;
}
.r-lid {
position: absolute;
background-color: #211a39;
width: 30%;
height: 250%;
transform: rotate(95deg);
-webkit-transform:rotate(95deg);
-ms-transform: rotate(95deg);
-os-transform: rotate(95deg);
top: -130%;
left: 80%;
}
.mouth {
position: absolute;
width: 30%;
height: 10%;
border-bottom-right-radius: 20px;
border-bottom-left-radius: 20px;
border: 2px solid #e299a4;
background-color: white;
top: 70%;
left: 35%;
}
.l-brow {
position: absolute;
background-color: #dec3ae;
border-radius: 50%;
width: 25%;
height:5%; /* adjust hight to control curve */
box-shadow:0.5px 2px 0px 0px #211a39; /*first controls vertical mvt, second controls horizontal mvt, others are blur and radius */
top: 32%;
left: 10%;
transform: rotate(185deg); /* flipped the shape to get an eyebrow */
-webkit-transform:rotate(185deg);
-ms-transform: rotate(185deg);
-os-transform: rotate(185deg);
}
.r-brow {
position: absolute;
background-color: #dec3ae;
border-radius: 50%;
width: 25%;
height:5%; /* adjust hight to control curve */
box-shadow:0.5px 2px 0px 0px #211a39; /*first controls vertical mvt, second controls horizontal mvt, others are blur and radius */
top: 32%;
right: 10%;
transform: rotate(175deg); /* flipped the shape to get an eyebrow */
-webkit-transform:rotate(175deg);
-ms-transform: rotate(175deg);
-os-transform: rotate(175deg);
}
.hair {
position: absolute;
background-color: black;
border-top-right-radius: 60px;
border-top-left-radius: 60px;
border-bottom-right-radius: 40px;
border-bottom-left-radius: 40px;
width: 150px;
height: 190px;
left: 31%;
top: 21%;
z-index: 1;
}
.neck {
position: absolute;
background-color: #d0b5a1;
border-radius: 40px;
width: 6%;
height: 10%;
top: 60%;
left: 47.3%;
z-index: 3;
}
.neck-shadow {
position: absolute;
background-color: #b6967d;
border-radius: 50px;
width: 100%;
height: 50%;
top: -1%;
z-index: 8;
}
.body {
position: absolute;
background-color: #1fa186;
border-top-right-radius: 50px;
border-top-left-radius: 50px;
top: 65%;
left: 35%;
width: 120px;
height: 130px;
z-index: 1;
}
/* Find a way to color only half a div */
.r-body {
position: absolute;
background-color: #1c947b;
border-top-right-radius: 50px;
border-top-left-radius: 20px;
top: 65%;
right: 35%;
width: 60px;
height: 128px;
z-index: 2;
}
.l-cover {
position: absolute;
background-color:#1fa186 ;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 10px;
transform: rotate(8deg);
-webkit-transform:rotate(8deg);
-ms-transform: rotate(8deg);
-os-transform: rotate(8deg);
width: 60px;
height: 15px;
top: 97%;
left: -1.26%;
z-index: 1;
}
.r-cover {
position: absolute;
background-color: #1c947b;
border-bottom-left-radius: 20px;
border-bottom-right-radius: 10px;
transform: rotate(-8deg);
-webkit-transform:rotate(-8deg);
-ms-transform: rotate(-8deg);
-os-transform: rotate(-8deg);
width: 60px;
height: 15px;
top: 97%;
left: -1.26%;
z-index: 1;
}
.l-hand {
position: absolute;
background: #dec3ae;
border-radius: 50%;
width: 30px;
height: 30px;
top: 95%;
left:44%;
z-index: 3;
}
.r-hand {
position: absolute;
background: #d5b296;
border-radius: 50%;
width: 30px;
height: 30px;
top: 95%;
right:44%;
z-index: 2;
}
.l-cheek {
position: absolute;
width:25px;
height: 25px;
background-color: #ea8c82;
opacity: 0.8;
border-radius: 50%;
top: 52%;
left: 7%;
}
.r-cheek {
position: absolute;
width:25px;
height: 25px;
background-color: #ea8c82;
opacity: 0.8;
border-radius: 50%;
top: 52%;
right: 7%;
}
/* Birthday hat and its decorations */
.hat {
position: absolute;
background: none;
width: 0;
height: 0;
border-left: 40px solid transparent; /* For transparent to work, background: none must be set1 */
border-right: 40px solid transparent;
border-bottom: 80px solid #ee7987;
top: 5%;
left: 40%;
}
.X1a {
position: absolute;
background: white;
opacity: 1;
width: 3px;
height: 20px;
/* top and margin-top doesn't work, when div elements are children of hat div, why */
transform: rotate(30deg);
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-os-transform: rotate(30deg);
top: 16%;
left: 45%;
z-index: 2;
}
.X1b {
position: absolute;
background: white;
opacity: 0.8;
width: 3px;
height: 16px;
/* top and margin-top doesn't work, when div elements are children of hat div, why */
transform: rotate(-30deg);
-webkit-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-os-transform: rotate(-30deg);
top: 16.5%;
left: 45%;
z-index: 2;
}
.X2a {
position: absolute;
background: white;
opacity: 0.7;
width: 3px;
height: 20px;
/* top and margin-top doesn't work, when div elements are children of hat div, why */
transform: rotate(30deg);
-webkit-transform: rotate(30deg);
-ms-transform: rotate(30deg);
-os-transform: rotate(30deg);
top: 16%;
left: 48%;
z-index: 2;
}
.X2b {
position: absolute;
background: white;
opacity: 0.6;
width: 3px;
height: 16px;
/* top and margin-top doesn't work, when div elements are children of hat div, why */
transform: rotate(-30deg);
-webkit-transform: rotate(-30deg);
-ms-transform: rotate(-30deg);
-os-transform: rotate(-30deg);
top: 16.5%;
left: 48%;
z-index: 2;
}
.I1 {
position: absolute;
background: white;
opacity: 0.6;
width: 3px;
height: 16px;
/* top and margin-top doesn't work, when div elements are children of hat div, why */
top: 16.5%;
left: 51%;
z-index: 2;
}
.I2 {
position: absolute;
background: white;
opacity: 0.5;
width: 3px;
height: 15px;
/* top and margin-top doesn't work, when div elements are children of hat div, why */
top: 16.75%;
left: 53%;
z-index: 2;
}
.I3 {
position: absolute;
background: white;
opacity: 0.4;
width: 3px;
height: 14px;
/* top and margin-top doesn't work, when div elements are children of hat div, why */
top: 17%;
left: 55%;
z-index: 2;
}
.dot {
position: absolute;
background: white;
width: 20px;
height: 20px;
border-radius: 50%;
box-shadow: 0px 0px 20px 5px white; /* REVIEW * fourth gives corner blur, last gives glow?*/
left: 47.65%;
top: 2%;
z-index: 3;
}
//getElementById("bg").style.backgroundColor = "#f69e54";
// how to cycle through different colors while clicking one button ?
Also see: Tab Triggers