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.
<main><a href="https://codepen.io/spAnser/full/wWmQGp/" class="button" target="_blank">Creature Naming</a>
<button id="editMode">Edit<br>Mode</button>
<button id="revertPlanet">Revert<br>Planet</button>
<header>
<img src="http://no-mans-sky.com/press/no_man's_sky/images/icon.png" alt="nms logo" />
<h1>Planet Naming</h1>
</header>
<section>
<h2>Biomes</h2>
<input type="radio" name="Biomes" value="Wa"><label>Water</label>
<input type="radio" name="Biomes" value="De"><label>Desert</label>
<input type="radio" name="Biomes" value="Mo"><label>Mountains</label>
<input type="radio" name="Biomes" value="Ca"><label>Caverns</label>
<input type="radio" name="Biomes" value="Si"><label>Snow/Ice</label>
<input type="radio" name="Biomes" value="Fo"><label>Forests</label>
<input type="radio" name="Biomes" value="Fi"><label>Floating Islands</label>
<input type="radio" name="Biomes" value="La"><label>Lacking Definition</label>
<input type="radio" name="Biomes" value="Ga"><label>Grassy Areas/Plains</label>
<input type="radio" name="Biomes" value="Ro"><label>Rocky</label>
<input type="radio" name="Biomes" value="Pi"><label>Pillars</label>
<input type="radio" name="Biomes" value="We"><label>Weird Stuff</label>
<div class="add">
<input type="text" placeholder="Wa" class="add-value">
<input type="text" placeholder="Water" class="add-label">
<button class="add-list">Add</button>
</div>
</section>
<section>
<h2>Resources</h2>
<input type="radio" name="Resources" value="cr"><label>Crafting</label>
<input type="radio" name="Resources" value="tr"><label>Trading</label>
<input type="radio" name="Resources" value="xr"><label>Exploring</label>
<input type="radio" name="Resources" value="ct"><label>Crafting/Trading</label>
<input type="radio" name="Resources" value="xc"><label>Exploring/Crafting</label>
<input type="radio" name="Resources" value="xt"><label>Exploring/Trading</label>
<input type="radio" name="Resources" value="mr"><label>Multi-Resources</label>
<input type="radio" name="Resources" value="nr"><label>No Resources</label>
<div class="add">
<input type="text" placeholder="cr" class="add-value">
<input type="text" placeholder="Crafting" class="add-label">
<button class="add-list">Add</button>
</div>
</section>
<section>
<h2>Life Forms</h2>
<input type="radio" name="Life Forms" value="i"><label>Flora/Fauna</label>
<input type="radio" name="Life Forms" value="o"><label>Other/NPC</label>
<input type="radio" name="Life Forms" value="e"><label>Flora/Fauna/NPC/Other</label>
<input type="radio" name="Life Forms" value="u"><label>Uninhabited</label>
<div class="add">
<input type="text" placeholder="i" class="add-value">
<input type="text" placeholder="Flora/Fauna" class="add-label">
<button class="add-list">Add</button>
</div>
</section>
<section>
<h2>Structures</h2>
<input type="radio" name="Structures" value="mo"><label>Monoliths</label>
<input type="radio" name="Structures" value="po"><label>Portals</label>
<input type="radio" name="Structures" value="bu"><label>Buildings</label>
<input type="radio" name="Structures" value="mu"><label>Monoliths/Buildings</label>
<input type="radio" name="Structures" value="pu"><label>Portals/Buildings</label>
<input type="radio" name="Structures" value="ma"><label>Monoliths/Portals</label>
<input type="radio" name="Structures" value="sa"><label>All</label>
<input type="radio" name="Structures" value="no"><label>None</label>
<div class="add">
<input type="text" placeholder="mo" class="add-value">
<input type="text" placeholder="Monoliths" class="add-label">
<button class="add-list">Add</button>
</div>
</section>
<section>
<h2>Law</h2>
<input type="radio" name="Law" value="s"><label>Sentinels</label>
<input type="radio" name="Law" value="l"><label>Lawless</label>
<div class="add">
<input type="text" placeholder="s" class="add-value">
<input type="text" placeholder="Sentinels" class="add-label">
<button class="add-list">Add</button>
</div>
</section>
<section>
<h2>Climate</h2>
<input type="radio" name="Climate" value="sa"><label>Safe</label>
<input type="radio" name="Climate" value="co"><label>Cold</label>
<input type="radio" name="Climate" value="bu"><label>Burn/Hot</label>
<input type="radio" name="Climate" value="to"><label>Toxic</label>
<input type="radio" name="Climate" value="ra"><label>Radiation</label>
<div class="add">
<input type="text" placeholder="sa" class="add-value">
<input type="text" placeholder="Safe" class="add-label">
<button class="add-list">Add</button>
</div>
</section>
<br>
<button class="top">Back to top</button>
</main>
<a href="https://www.reddit.com/r/NoMansSkyTheGame/comments/4tt5ak/planet_naming_convention_updated/" id="credit" target="_blank">Original idea from IIIAnomalyIII (Updated)</a>
* {
box-sizing: border-box;
font-family: 'Open Sans', Helvetica, Verdana, Arial, sans-serif;
color: #3f3f3f;
outline: 0;
}
html {
height: 100%;
min-height: 100%;
padding: 0;
margin: 0;
}
body {
height: 100%;
min-height: 100px;
padding: 0;
margin: 0;
background: url("http://no-mans-sky.com/press/no_man's_sky/images/Walkers.png") 50% 50% fixed / cover;
background-position: center center;
text-align: center;
}
#credit {
position: relative;
display: inline-block;
padding: 10px;
margin: 10px auto;
color: #eee;
background: rgba(0,0,0,.7);
}
button, .button {
padding: 10px;
margin: 10px;
color: #eee;
background: rgba(0,0,0,.7);
border: 0;
outline: 0;
transition: background .3s;
text-decoration: none;
}
header {
width: 100%;
text-align: center;
}
header h1 {
line-height: 10vw;
padding: 0 70px;
font-size: 6vw;
margin: 0;
height: 16vw;
display: inline-block;
vertical-align: middle;
transition: all .3s;
}
header h1 input {
font-size: 6vw;
width: 80%;
border: 1px solid #000;
padding: 0 10px;
text-align: center;
}
header h1:hover div,
main.editting h1 div {
margin: 0;
font-size: 60%;
opacity: .5;
line-height: 2vw;
}
h1 span {
display: inline-block;
width: 0;
opacity: 0;
margin: 0 .75rem 0 -.75rem;
transition: width .3s, opacity .3s, margin .3s;
}
header h1:hover span,
main.editting h1 span {
opacity: 1;
width: 1.5rem;
margin: 0;
}
header h1 div {
margin-top: -10vw;
transition: all .3s;
vertical-align: text-top;
}
header img {
display: inline-block;
vertical-align: middle;
position: absolute;
top: 20px;
left: 20px;
width: 7vw;
height: auto;
}
main {
position: relative;
display: block;
margin: 0 auto;
padding: 20px;
background: rgba(255,255,255,.7);
text-align: center;
width: 70%;
min-width: 300px;
transition: all .3s;
}
section {
text-align: left;
display: inline-block;
padding: 20px 20px 0;
vertical-align: top;
width: 16%;
min-width: 200px;
}
section h2 {
margin: 0 0 20px;
cursor: default;
position: relative;
transition: margin .3s;
}
section h2.closed {
margin: 0;
}
section h2:after {
content: '';
border-top: 6px solid #3f3f3f;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 0;
position: absolute;
top: .5em;
right: 0;
transition: all .3s;
}
section h2.closed:after {
transform: rotate(90deg);
}
section label {
float: left;
clear: left;
line-height: 1.5em;
padding: 0 5px;
margin: 0 -5px;
border: 1px solid transparent;
border-bottom: 2px solid transparent;
border-left: 2px solid transparent;
cursor: pointer;
position: relative;
}
section input[type=radio] {
display: none;
}
section label.checked {
text-shadow: 1px 0 0;
border-bottom: solid 2px;
border-left: solid 2px;
}
section label span {
position: absolute;
top: 0;
right: 100%;
margin: 0;
padding: 0 2px;
opacity: 0;
text-align: right;
transition: opacity .3s, background .3s, margin .3s;
}
main.editting section label span {
margin: 0 0 0 -2em;
opacity: 1;
background: #fff;
}
main.editting section label.checked span {
border-bottom: solid 2px;
border-left: solid 2px;
}
#editMode {
position: absolute;
top: 0;
right: 0;
border: solid 1px rgba(0,0,0,.7);
background: none;
color: rgba(0,0,0,.7);
}
#revertPlanet {
position: absolute;
top: 62px;
right: 0;
border: solid 1px rgba(0,0,0,.7);
background: none;
color: rgba(0,0,0,.7);
}
#revertPlanet:disabled {
opacity: .4;
border-color: red;
color: red;
}
main.editting {
background: #fff;
}
main.editting #editMode {
background: green;
border-color: green;
color: #fff;
}
main section .add {
opacity: 0;
padding: 10px 0 0;
margin: 0 -30px 0 0;
clear: left;
transition: opacity .3s;
}
main.editting section .add {
opacity: 1;
}
main section .add input[type=text] {
border: #333 solid 1px;
padding: 5px;
}
main section .add .add-value {
width: 2.5em;
}
main section .add .add-label {
width: 7em;
}
main section .add button {
margin: 0;
padding: 5px;
border: 1px solid rgba(0,0,0,.5);
}
main section .add input[type=text]:focus,
main section .add button:focus {
border: 2px solid #000;
padding: 4px;
}
var editMode = false;
// give labels for and inputs id cause I'm lazy
// also for scalability when implementing customisability
function lazyLabel(){
$('label').each(function(i){
$(this).attr('for',i);
$(this).prepend('<span>'+$(this).prev().val()+'</span>');
$(this).prev().attr('id',i);
});
}
lazyLabel();
$('section').on('change','input',function() {
if(this.checked){
var planet = {
biomes : $('input:radio[name=Biomes]:checked').val(),
resources : $('input:radio[name=Resources]:checked').val(),
lifeforms : $('input:radio[name="Life Forms"]:checked').val(),
structures : $('input:radio[name=Structures]:checked').val(),
law : $('input:radio[name=Law]:checked').val(),
climate : $('input:radio[name=Climate]:checked').val()
},
update = true;
for(var val in planet){
if(planet[val] === undefined){
update = false;
}
}
if(update){
if($('#revertPlanet').attr('checking')){
$('h1').html($('h1').data('stored'));
$('#revertPlanet').text('Revert Planet').removeAttr('checking').prop('disabled',false);
}
$('h1').html(planet.biomes+planet.resources+planet.lifeforms+planet.structures+planet.law+planet.climate+'<div>'+planet.biomes+'<span>-</span>'+planet.resources+'<span>-</span>'+planet.lifeforms+'<span>-</span>'+planet.structures+'<span>-</span>'+planet.law+'<span>-</span>'+planet.climate+'</div>');
}
$(this).siblings().removeClass('checked');
$(this).next().addClass('checked');
}
});
$('h2').click(function(){
$(this).toggleClass('closed').parents('section').find('label,div.add').stop().slideToggle();
})
$('#editMode').click(function(){
if(editMode){
editMode = false;
$('main').removeClass('editting');
} else {
editMode = true;
if($('#revertPlanet').attr('checking')){
$('h1').html($('h1').data('stored'));
$('#revertPlanet').text('Revert Planet').removeAttr('checking').prop('disabled',false);
}
$('main').addClass('editting');
}
});
$('#revertPlanet').click(function(){
if(!$(this).attr('checking')){
$('h1').attr('data-stored',$('h1').html()).html('<input type="text" placeholder="Planet Name">');
$('h1 input').focus();
$(this).text('Revert').attr('checking',true).prop('disabled',true);
} else {
if($('h1 input').val().trim().length == 10){
var name = $('h1 input').val().trim().toLowerCase(),
name = name[0].toUpperCase()+name.substr(1,name.length-1),
name = [name[0]+name[1],name[2]+name[3],name[4],name[5]+name[6],name[7],name[8]+name[9]];
for(var param in name){
$('section').eq(param).find('input[value='+name[param]+']').next()[0].click();
}
$(this).text('Revert Planet').removeAttr('checking').prop('disabled',false);
}
}
});
$('h1').on('keyup','input',function(e){
if($(this).val().trim().length != 10){
$('#revertPlanet').prop('disabled',true);
} else {
$('#revertPlanet').prop('disabled',false);
}
if(e.keyCode == 13){
$('#revertPlanet').click();
}
});
$('.add-list').click(function(){
var $this = $(this),
value = $this.prev().prev().val().toLowerCase(),
label = $this.prev().val();
if(value != '' && label != ''){
// if start of planet name, force capitalise
if($this.parents('section').find('h2').text() == 'Biomes'){
value = value[0].toUpperCase()+value.substr(1,value.length-1);
}
$this.parent().before('<input type="radio" name="'+$this.parents('section').find('h2').text()+'" value="'+value+'"><label>'+label+'</label>');
$this.prev().val('').prev().val('');
lazyLabel();
}
});
$('.top').click(function(){
$('html,body').animate({
scrollTop: 0
}, 500);
})
Also see: Tab Triggers