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.
<div class="game"></div>
/* colors */
$white: #FFFFFF;
$gray: #D9D9D9;
$yellow: #CAC65D;
$red: #CA5D5D;
$blue: #5D75CA;
$green: #60CA5D;
$light-blue1: #DEF9F1;
$light-blue2: #C1EFE1;
/*dimensions */
$full: 100vh;
/* Presets */
*, *:before, *:after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
position: relative;
z-index: 1;
perspective-origin: 25% 75%;
background: linear-gradient(187.47deg, $light-blue1 15%, $light-blue2 100%);
perspective: 700px;
perspective-origin: 50% 50%;
}
div:before, div:after {
display: block;
content: '';
position: absolute;
}
div.game {
width: 100vw;
height: 100vh;
margin-top: -30vh;
position: relative;
display: flex;
justify-content: center;
align-items: center;
transform: rotateX(15deg);
background:
/* cable */ linear-gradient(90deg, darken($gray, 35%) 0vh, darken($gray, 65%) 100vh, transparent 3vh) 57.5vh 0vh / 1.5vh 50vh no-repeat, /* cable-stop */ linear-gradient( darken($gray, 35%) 10vh, darken($gray, 35%) 10vh, transparent 3vh) 53vh 48vh / 11vh 2vh no-repeat,
/* atop */ linear-gradient( darken($gray, 5%) 10vh, darken($gray, 5%) 10vh, transparent 3vh) 51vh 52vh / 15vh 7vh no-repeat,
/* LEFT SIDE */
/* up-tri-l */ linear-gradient(-55deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 38.5vh 57vh / 1.5vh 1.5vh no-repeat,
/* up-tri-r */ linear-gradient(55deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 40vh 57vh / 1.5vh 1.5vh no-repeat,
/* up */ linear-gradient( darken($gray, 65%) 10vh, darken($gray, 65%) 10vh, transparent 3vh) 37.5vh 56vh / 5vh 7vh no-repeat,
/* down-tri-l */ linear-gradient(-125deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 38.5vh 67vh / 1.5vh 1.5vh no-repeat,
/* down-tri-r */ linear-gradient(125deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 40vh 67vh / 1.5vh 1.5vh no-repeat,
/* down */ linear-gradient( darken($gray, 65%) 10vh, darken($gray, 65%) 10vh, transparent 3vh) 37.5vh 63vh / 5vh 7vh no-repeat,
/* depth-b */ linear-gradient(-115deg, darken($gray, 85%) 1vh, transparent 1vh) 37.5vh 69.75vh / 1vh 1vh no-repeat,
/* depth-b */ linear-gradient(115deg, darken($gray, 70%) 1vh, transparent 1vh) 41.5vh 69.75vh / 1vh 1vh no-repeat,
/* depth-b */ linear-gradient( darken($gray, 70%) 10vh, darken($gray, 70%) 10vh, transparent 3vh) 38vh 69.75vh / 4vh 1vh no-repeat,
/* left-tri-l */ linear-gradient(-145deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 34vh 62.25vh / 1.5vh 1.5vh no-repeat,
/* left-tri-r */ linear-gradient(-35deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 34vh 60.75vh / 1.5vh 1.5vh no-repeat,
/* left */ linear-gradient( darken($gray, 65%) 10vh, darken($gray, 65%) 10vh, transparent 3vh) 33vh 60vh / 7vh 5vh no-repeat,
/* left */ linear-gradient(-115deg, darken($gray, 85%) 1vh, transparent 1vh) 33.1vh 64.75vh / 1vh 1vh no-repeat,
/* left */ linear-gradient( darken($gray, 70%) 10vh, darken($gray, 70%) 10vh, transparent 3vh) 34vh 63.75vh / 8vh 2vh no-repeat,
/* right-tri-l */ linear-gradient(145deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 44.5vh 62.25vh / 1.5vh 1.5vh no-repeat,
/* right-tri-r */ linear-gradient(35deg, darken($white, 20%), 0.75vh, transparent 0.75vh) 44.5vh 60.75vh / 1.5vh 1.5vh no-repeat,
/* right */ linear-gradient( darken($gray, 65%) 10vh, darken($gray, 65%) 10vh, transparent 3vh) 40vh 60vh / 7vh 5vh no-repeat,
/* depth-r */ linear-gradient(115deg, darken($gray, 70%) 1vh, transparent 1vh) 46vh 64.75vh / 1vh 1vh no-repeat,
/* depth-r */ linear-gradient( darken($gray, 70%) 10vh, darken($gray, 70%) 10vh, transparent 3vh) 40vh 63.75vh / 6vh 2vh no-repeat,
/* l */radial-gradient(circle, $white 10vh, transparent 10vh) 15vh 38vh / 50vh 50vh no-repeat,
/* l */radial-gradient(circle, $gray 13vh, transparent 13vh) 15vh 38vh / 50vh 50vh no-repeat,
/* RIGHT SIDE */
/* red */radial-gradient(circle, $red 2.5vh, transparent 2.5vh) 80vh 60vh / 5vh 5vh no-repeat,
/* red */radial-gradient(circle, darken($red, 15%) 2.5vh, transparent 2.5vh) 80vh 60.5vh / 5vh 5vh no-repeat,
/* green */radial-gradient(circle, $green 2.5vh, transparent 2.5vh) 75vh 65vh / 5vh 5vh no-repeat,
/* green */radial-gradient(circle, darken($green, 15%) 2.5vh, transparent 2.5vh) 75vh 65.5vh / 5vh 5vh no-repeat,
/* blue */radial-gradient(circle, $blue 2.5vh, transparent 2.5vh) 70vh 60vh / 5vh 5vh no-repeat,
/* depth-blue */radial-gradient(circle, darken($blue, 15%) 2.5vh, transparent 2.5vh) 70vh 60.5vh / 5vh 5vh no-repeat,
/* yellow */radial-gradient(circle, $yellow 2.5vh, transparent 2.5vh) 75vh 55vh / 5vh 5vh no-repeat,
/* depth-yellow */radial-gradient(circle, darken($yellow, 15%) 2.5vh, transparent 2.5vh) 75vh 55.5vh / 5vh 5vh no-repeat,
/* r */radial-gradient(circle, $white 10vh, transparent 10vh) 52vh 38vh / 50vh 50vh no-repeat,
/* r */radial-gradient(circle, $gray 13vh, transparent 13vh) 52vh 38vh / 50vh 50vh no-repeat,
/* CENTER SIDE */
/* select */radial-gradient(ellipse, darken($gray, 45%) 2vh, transparent 2vh) 55vh 60vh / 3vh 5vh no-repeat,
/* select */radial-gradient(ellipse, darken($gray, 55%) 2vh, transparent 2vh) 55vh 60.75vh / 3vh 5vh no-repeat,
/* start */radial-gradient(ellipse, darken($gray, 45%) 2vh, transparent 2vh) 59vh 60vh / 3vh 5vh no-repeat,
/* start */radial-gradient(ellipse, darken($gray, 55%) 2vh, transparent 2vh) 59vh 60.75vh / 3vh 5vh no-repeat,
/* base */ linear-gradient( $gray 30vh, $gray 30vh, transparent 3vh) 38vh 50vh / 40vh 17vh no-repeat,
/* CENTER SIDE */
/* yellow */radial-gradient(ellipse, darken($gray, 45%) 2vh, transparent 2vh) 55vh 60vh / 3vh 5vh no-repeat,
/* yellow */radial-gradient(ellipse, darken($gray, 45%) 2vh, transparent 2vh) 59vh 60vh / 3vh 5vh no-repeat,
/* DEPTH SIDE */
/* base */ linear-gradient( darken($gray, 10%) 30vh, darken($gray, 10%) 30vh, transparent 3vh) 50vh 63vh / 15vh 7vh no-repeat,
/* depth-l */radial-gradient(circle, darken($gray, 10%) 13vh, transparent 13vh) 14.5vh 41vh / 52vh 50vh no-repeat,
/* depth-r */radial-gradient(circle, darken($gray, 10%) 13vh, transparent 13vh) 50.5vh 41vh / 52vh 50vh no-repeat;
}
/* This entry was an attempt at trying to do something simple but polished, a respite from some of the complex versions I have been working on the first week of divtober. Still couldn't help trying to figure out perspective again. There is a time-lapse video of making this piece at https://youtu.be/88fKEUnMgNs */
Also see: Tab Triggers