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.
<form>
<div class="board">
<div id="scorebar">Your scores: </div>
<input id="bonus_01" name="radio1" class="bonus" type="radio">
<input id="bonus_02" name="radio2" class="bonus" type="radio">
<input id="bonus_03" name="radio3" class="bonus" type="radio">
<input id="bonus_04" name="radio4" class="bonus" type="radio">
<input id="bonus_05" name="radio5" class="bonus" type="radio">
<input id="bonus_06" name="radio6" class="bonus" type="radio">
<input id="bonus_07" name="radio7" class="bonus" type="radio">
<input id="bonus_08" name="radio8" class="bonus" type="radio">
<input id="bonus_09" name="radio9" class="bonus" type="radio">
<input id="bonus_10" name="radio10" class="bonus" type="radio">
<p class="enemy" id="enemy_01"></p>
<p class="enemy" id="enemy_02"></p>
<p class="enemy" id="enemy_03"></p>
<p class="enemy enemy_t1" id="enemy_04"></p>
<p class="enemy" id="enemy_05"></p>
<p class="enemy" id="enemy_06"></p>
<p class="enemy enemy_t3" id="enemy_07"></p>
<p class="enemy" id="enemy_08"></p>
<p class="enemy" id="enemy_09"></p>
<p class="enemy" id="enemy_10"></p>
<p class="enemy enemy_t1" id="enemy_11"></p>
<p class="enemy" id="enemy_12"></p>
<p class="enemy" id="enemy_13"></p>
<p class="enemy enemy_t2" id="enemy_14"></p>
<p class="enemy" id="enemy_15"></p>
<p class="enemy" id="enemy_16"></p>
<p class="enemy enemy_t3" id="enemy_17"></p>
<p class="enemy" id="enemy_18"></p>
<p class="enemy" id="enemy_19"></p>
<p class="enemy enemy_t3" id="enemy_20"></p>
<p class="enemy" id="enemy_21"></p>
<p class="enemy" id="enemy_22"></p>
<p class="enemy enemy_t1" id="enemy_23"></p>
<p class="enemy" id="enemy_24"></p>
<p class="enemy enemy_t2" id="enemy_25"></p>
<p class="enemy" id="enemy_26"></p>
<p class="enemy" id="enemy_27"></p>
<p class="enemy enemy_t3" id="enemy_28"></p>
<p class="enemy" id="enemy_29"></p>
<p class="enemy" id="enemy_30"></p>
<p class="enemy" id="enemy_31"></p>
<p class="enemy" id="enemy_32"></p>
<p class="enemy" id="enemy_33"></p>
<p class="enemy" id="enemy_34"></p>
<p class="enemy" id="enemy_35"></p>
<p class="enemy" id="enemy_36"></p>
<p class="enemy" id="enemy_37"></p>
<p class="enemy" id="enemy_38"></p>
<p class="enemy enemy_t3" id="enemy_39"></p>
<p class="enemy" id="enemy_40"></p>
<p class="enemy" id="enemy_41"></p>
<p class="enemy" id="enemy_42"></p>
<p class="enemy" id="enemy_43"></p>
<p class="enemy enemy_t2" id="enemy_44"></p>
<p class="enemy" id="enemy_45"></p>
<p class="enemy" id="enemy_46"></p>
<p class="enemy enemy_t1" id="enemy_47"></p>
<p class="enemy" id="enemy_48"></p>
<p class="enemy" id="enemy_49"></p>
<p class="enemy" id="enemy_50"></p>
<p id="finish">Congratulations! You just played a game that is written in JS and contains a total of 0 lines of code.</p>
<p id="status"><strong>Help:</strong> <span class="inactive">move cursor to the field.</span><span class="active">Ships fly around the halls, click on bonuses!</span></p>
</div>
</div>
<center>
<embed src="https://www.zapsplat.com/wp-content/uploads/2015/music-game/music_zapsplat_easy_cheesy.mp3" loop="true" autostart="true" width="20" height="10"></embed>
<br>
<audio controls autoplay loop autostart>
<source src="https://www.zapsplat.com/wp-content/uploads/2015/music-game/music_zapsplat_easy_cheesy.mp3" type="audio/mp3">
</audio>
</center>
</form>
html {
height: 100%;
background-color: #222;
background-image: linear-gradient(180deg, transparent, hsla(30, 10%, 70%, 1) 0), linear-gradient(-45deg, hsla(30, 10%, 70%, 1) 40%, transparent 0), linear-gradient(45deg, hsla(30, 10%, 70%, 1) 40%, transparent 0), linear-gradient(45deg, transparent 40%, hsla(30, 10%, 70%, 1) 0), linear-gradient(-45deg, transparent 40%, hsla(30, 10%, 70%, 1) 0), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(45deg, transparent 40%, hsla(30, 10%, 70%, 1) 0), linear-gradient(-45deg, transparent 40%, hsla(30, 10%, 70%, 1) 0), linear-gradient(45deg, transparent 40%, hsla(30, 10%, 70%, 1) 0), linear-gradient(-45deg, transparent 40%, hsla(30, 10%, 70%, 1) 0), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(hsla(30, 10%, 70%, 1), hsla(30, 10%, 70%, 1)), linear-gradient(180deg, hsla(10, 60%, 40%, 1), hsla(10, 60%, 40%, 1), hsla(200, 30%, 100%, 1), hsla(200, 30%, 50%, 1), hsla(200, 50%, 70%, 1), hsla(250, 40%, 40%, 1), hsla(250, 20%, 50%, 1), hsla(290, 0%, 30%, 1), hsla(10, 60%, 40%, 1));
background-position: 50% 100%, calc(50% - 15px) calc(100% - 145px), calc(50% + 15px) calc(100% - 145px), calc(50% - 20px) calc(100% - 140px), calc(50% + 20px) calc(100% - 140px), 50% calc(100% - 135px), calc(50% - 15px) calc(100% - 130px), calc(50% + 15px) calc(100% - 130px), calc(50% - 10px) calc(100% - 120px), calc(50% + 10px) calc(100% - 120px), 50% calc(100% - 70px), calc(50% + 5px) calc(100% - 75px), calc(50% + 20px) calc(100% - 80px), calc(50% + 25px) calc(100% - 79px), calc(50% + 35px) calc(100% - 53px), calc(50% + 35px) calc(100% - 70px), 50% 100%, 0 0;
background-size: 15px 161px, 30px 20px, 30px 20px, 30px 5px, 30px 5px, 40px 5px, 30px 5px, 30px 5px, 30px 5px, 30px 5px, 25px 30px, 25px 20px, 30px 5px, 3px 7px, 5px 30px, 7px 3px, 2px 185px, 100% 1500%;
background-repeat: no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, no-repeat, repeat-y;
animation: weather 840s linear infinite;
}
html:after, html:before {
content: '';
position: absolute;
border-radius: 50%;
z-index: 1;
}
html:before {
height: 150px;
width: 150px;
box-shadow: inset 20px -20px 50px hsla(295, 20%, 70%, .5);
top: 20%;
right: 5%;
}
html:after {
height: 100px;
width: 100px;
box-shadow: inset 30px -30px 50px hsla(230, 20%, 60%, .5);
top: 35%;
right: 15%;
}
@keyframes weather {
to {
background-position: 50% 100%, calc(50% - 15px) calc(100% - 145px), calc(50% + 15px) calc(100% - 145px), calc(50% - 20px) calc(100% - 140px), calc(50% + 20px) calc(100% - 140px), 50% calc(100% - 135px), calc(50% - 15px) calc(100% - 130px), calc(50% + 15px) calc(100% - 130px), calc(50% - 10px) calc(100% - 120px), calc(50% + 10px) calc(100% - 120px), 50% calc(100% - 70px), calc(50% + 5px) calc(100% - 75px), calc(50% + 20px) calc(100% - 80px), calc(50% + 25px) calc(100% - 79px), calc(50% + 35px) calc(100% - 53px), calc(50% + 35px) calc(100% - 70px), 50% 100%, 0 1500%;
}
}
@keyframes weather {
to {
background-position: 50% 100%, calc(50% - 15px) calc(100% - 145px), calc(50% + 15px) calc(100% - 145px), calc(50% - 20px) calc(100% - 140px), calc(50% + 20px) calc(100% - 140px), 50% calc(100% - 135px), calc(50% - 15px) calc(100% - 130px), calc(50% + 15px) calc(100% - 130px), calc(50% - 10px) calc(100% - 120px), calc(50% + 10px) calc(100% - 120px), 50% calc(100% - 70px), calc(50% + 5px) calc(100% - 75px), calc(50% + 20px) calc(100% - 80px), calc(50% + 25px) calc(100% - 79px), calc(50% + 35px) calc(100% - 53px), calc(50% + 35px) calc(100% - 70px), 50% 100%, 0 1500%;
}
}
* {
margin: 0;
padding: 0;
}
.board {
width: 400px;
height: 600px;
margin: 0 auto;
background: #69c url(https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/bg.jpg);
cursor: url('https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/r2.png') 35 0,pointer;
text-align: center;
position: relative;
}
#scorebar {
float: left;
color: #fff;
}
.board #status {
color: #fff;
position: absolute;
bottom: 15px;
left: 5px;
font-size: 14px;
}
.board #status span.active {
display: none;
}
.board #status span.inactive {
display: inline;
}
.board:hover #status span.active {
display: inline;
}
.board:hover #status span.inactive {
display: none;
}
.enemy {
height: 64px;
width: 64px;
margin-right: 5px;
margin-top: 15px;
position: absolute;
top: -50%;
left: 0;
background: url(https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/e6.png);
}
.enemy_t1 {
height: 48px;
width: 48px;
background: url(https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/e4.png);
}
.enemy_t2 {
height: 64px;
width: 64px;
background: url(https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/e2.png);
}
.enemy_t3 {
height: 128px;
width: 128px;
background: url(https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/e3.png);
}
.bonus {
height: 24px;
width: 24px;
position: absolute;
top: -10%;
left: 0;
background-image: url(https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/b1.png);
-moz-appearance: button;
-webkit-appearance: button;
appearance: button;
}
.bonus:checked {
background-image: url('https://raw.githubusercontent.com/frontdevops/nojsgame/master/assets/img/b2.png') !important;
width: 24px;
height: 24px;
position: static;
-webkit-animation-name: none;
animation-name: none;
float: left;
}
.board .enemy:hover {
border-radius: 0;
margin: 0;
height: 600px;
width: 400px;
position: absolute;
top: 0;
left: 0;
z-index: 999;
background: #f00;
overflow: visible;
cursor: not-allowed;
animation: animation1 0s 0s linear !important;
animation: animation2 0s 0s linear !important;
animation: animation3 0s 0s linear !important;
animation: animation4 0s 0s linear !important;
animation: animation5 0s 0s linear !important;
animation: animation6 0s 0s linear !important;
animation: animation7 0s 0s linear !important;
animation: animation8 0s 0s linear !important;
animation: animation9 0s 0s linear !important;
animation: animation10 0s 0s linear !important;
}
.board .enemy:hover:before {
background: #f00;
content: "GAME OVER!";
top: 30%;
left: 0;
width: 400px;
color: #fff;
text-shadow: 1px 1px 1px #aaa;
box-shadow: none;
position: relative;
}
.board .enemy:hover:after {
display: none;
}
.board .bonus:hover {
cursor: crosshair;
zoom: 2;
}
.board:hover #bonus_01 {
animation: animation3 8s 2s linear;
}
.board:hover #bonus_02 {
animation: animation4 12s 4s linear;
}
.board:hover #bonus_03 {
animation: animation8 16s 6s linear;
}
.board:hover #bonus_04 {
animation: animation2 16s 10s linear;
}
.board:hover #bonus_05 {
animation: animation9 14s 15s linear;
}
.board:hover #bonus_06 {
animation: animation7 12s 20s linear;
}
.board:hover #bonus_07 {
animation: animation1 8s 26s linear;
}
.board:hover #bonus_08 {
animation: animation3 10s 30s linear;
}
.board:hover #bonus_09 {
animation: animation7 16s 40s linear;
}
.board:hover #bonus_10 {
animation: animation4 16s 45s linear;
}
.board:hover #enemy_01 {
animation: animation1 6s 0s linear;
}
.board:hover #enemy_02 {
animation: animation2 5s 2s linear;
}
.board:hover #enemy_03 {
animation: animation3 3s 3s linear;
}
.board:hover #enemy_04 {
animation: animation4 6s 4s linear;
}
.board:hover #enemy_05 {
animation: animation5 4s 5s linear;
}
.board:hover #enemy_06 {
animation: animation2 3s 6s linear;
}
.board:hover #enemy_07 {
animation: animation7 2s 8s linear;
}
.board:hover #enemy_08 {
animation: animation4 5s 8s linear;
}
.board:hover #enemy_09 {
animation: animation8 3s 9s linear;
}
.board:hover #enemy_10 {
animation: animation6 4s 10s linear;
}
.board:hover #enemy_11 {
animation: animation1 6s 10s linear;
}
.board:hover #enemy_12 {
animation: animation6 4s 11s linear;
}
.board:hover #enemy_13 {
animation: animation2 8s 12s linear;
}
.board:hover #enemy_14 {
animation: animation9 4s 13s linear;
}
.board:hover #enemy_15 {
animation: animation3 5s 13s linear;
}
.board:hover #enemy_16 {
animation: animation10 7s 14s linear;
}
.board:hover #enemy_17 {
animation: animation7 3s 15s linear;
}
.board:hover #enemy_18 {
animation: animation3 5s 16s linear;
}
.board:hover #enemy_19 {
animation: animation6 4s 16s linear;
}
.board:hover #enemy_20 {
animation: animation1 3s 17s linear;
}
.board:hover #enemy_21 {
animation: animation2 4s 17s linear;
}
.board:hover #enemy_22 {
animation: animation1 5s 18s linear;
}
.board:hover #enemy_23 {
animation: animation4 9s 19s linear;
}
.board:hover #enemy_24 {
animation: animation9 2s 20s linear;
}
.board:hover #enemy_25 {
animation: animation7 3s 20s linear;
}
.board:hover #enemy_26 {
animation: animation1 5s 20s linear;
}
.board:hover #enemy_27 {
animation: animation9 6s 21s linear;
}
.board:hover #enemy_28 {
animation: animation3 3s 22s linear;
}
.board:hover #enemy_29 {
animation: animation6 4s 23s linear;
}
.board:hover #enemy_30 {
animation: animation4 5s 24s linear;
}
.board:hover #enemy_31 {
animation: animation9 4s 24s linear;
}
.board:hover #enemy_32 {
animation: animation6 2s 25s linear;
}
.board:hover #enemy_33 {
animation: animation3 3s 26s linear;
}
.board:hover #enemy_34 {
animation: animation4 5s 26s linear;
}
.board:hover #enemy_35 {
animation: animation10 8s 27s linear;
}
.board:hover #enemy_36 {
animation: animation2 3s 27s linear;
}
.board:hover #enemy_37 {
animation: animation7 2s 28s linear;
}
.board:hover #enemy_38 {
animation: animation4 5s 28s linear;
}
.board:hover #enemy_39 {
animation: animation1 3s 29s linear;
}
.board:hover #enemy_40 {
animation: animation6 4s 30s linear;
}
.board:hover #enemy_41 {
animation: animation9 4s 24s linear;
}
.board:hover #enemy_42 {
animation: animation6 2s 25s linear;
}
.board:hover #enemy_43 {
animation: animation3 3s 26s linear;
}
.board:hover #enemy_44 {
animation: animation4 5s 26s linear;
}
.board:hover #enemy_45 {
animation: animation10 8s 27s linear;
}
.board:hover #enemy_46 {
animation: animation2 3s 27s linear;
}
.board:hover #enemy_47 {
animation: animation7 2s 28s linear;
}
.board:hover #enemy_48 {
animation: animation4 5s 28s linear;
}
.board:hover #enemy_49 {
animation: animation1 3s 29s linear;
}
.board:hover #enemy_50 {
animation: animation6 4s 30s linear;
}
@keyframes animation1 {
0% {
left: 260px;
top: -10%;
}
100% {
left: 260px;
top: 100%;
}
}
@keyframes animation2 {
0% {
left: 50px;
top: -10%;
}
100% {
left: 50px;
top: 100%;
}
}
@keyframes animation3 {
0% {
left: 150px;
top: -10%;
}
100% {
left: 200px;
top: 100%;
}
}
@keyframes animation4 {
0% {
left: 300px;
top: -10%;
}
100% {
left: 200px;
top: 100%;
}
}
@keyframes animation5 {
0% {
left: 150px;
top: -10%;
}
100% {
left: 150px;
top: 100%;
}
}
@keyframes animation6 {
0% {
left: 50px;
top: -10%;
}
100% {
left: 250px;
top: 100%;
}
}
@keyframes animation7 {
0% {
left: 300px;
top: -10%;
}
100% {
left: 0;
top: 100%;
}
}
@keyframes animation8 {
0% {
left: 0;
top: -10%;
}
100% {
left: 300px;
top: 100%;
}
}
@keyframes animation9 {
0% {
left: 200px;
top: -10%;
}
100% {
left: 150px;
top: 100%;
}
}
@keyframes animation10 {
0% {
left: 250px;
top: -10%;
}
100% {
left: 100px;
top: 100%;
}
}
@keyframes animation99 {
0% {
left: 50px;
top: -40%;
}
100% {
left: 50px;
top: 30%;
}
}
@keyframes animation1 {
0% {
left: 260px;
top: -10%;
}
100% {
left: 260px;
top: 100%;
}
}
@keyframes animation2 {
0% {
left: 50px;
top: -10%;
}
100% {
left: 50px;
top: 100%;
}
}
@keyframes animation3 {
0% {
left: 150px;
top: -10%;
}
100% {
left: 200px;
top: 100%;
}
}
@keyframes animation4 {
0% {
left: 300px;
top: -10%;
}
100% {
left: 200px;
top: 100%;
}
}
@keyframes animation5 {
0% {
left: 150px;
top: -10%;
}
100% {
left: 150px;
top: 100%;
}
}
@keyframes animation6 {
0% {
left: 50px;
top: -10%;
}
100% {
left: 250px;
top: 100%;
}
}
@keyframes animation7 {
0% {
left: 300px;
top: -10%;
}
100% {
left: 0;
top: 100%;
}
}
@keyframes animation8 {
0% {
left: 0;
top: -10%;
}
100% {
left: 300px;
top: 100%;
}
}
@keyframes animation9 {
0% {
left: 200px;
top: -10%;
}
100% {
left: 150px;
top: 100%;
}
}
@keyframes animation10 {
0% {
left: 250px;
top: -10%;
}
100% {
left: 100px;
top: 100%;
}
}
@keyframes animation99 {
0% {
left: 50px;
top: -40%;
}
100% {
left: 50px;
top: 30%;
}
}
.board #finish {
position: absolute;
top: -40%;
left: 50px;
text-align: center;
display: none;
width: 200px;
padding: 20px 50px;
background: #fff;
box-shadow: 4px 4px 4px #ccc;
border-radius: 10px;
}
.board:hover #finish {
-webkit-animation: animation99 5s 30s linear;
animation: animation99 5s 30s linear;
animation-fill-mode: forwards;
display: block;
}
// 0 lines of JS code
Also see: Tab Triggers