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>
<h1>CSS Radial and Conic Gradients</h1>
<p class="intro">CSS <code>radial-gradient()</code> and <code>repeating-radial-gradient()</code> functions allow to compute amazing radial gradients without need to use external graphics software. A conic gradient created with <code>conic-gradient()</code> function is also an interesting alternative.</p>
<section class="history">
<!--
To create a radial gradient - simply provide two colors.
-->
<div style="background: radial-gradient(black, darkcyan)"><span>basic</span></div>
<!--
The colors can names or hex values or RGB decimal values.
-->
<div style="background: radial-gradient(#000000, #008B8B)"><span>hex</span></div>
<!--
As the first parameter, we can provide the position of the center
of the gradient. By default it is center. Other possibilities
include top, right, left and bottom for sides
and a mix of those for corners.
-->
<div style="background: radial-gradient(at center, black, darkcyan)"><span>center</span></div>
<div style="background: radial-gradient(at left, black, darkcyan)"><span>left</span></div>
<div style="background: radial-gradient(at right, black, darkcyan)"><span>right</span></div>
<div style="background: radial-gradient(at top, black, darkcyan)"><span>top</span></div>
<div style="background: radial-gradient(at bottom, black, darkcyan)"><span>bottom</span></div>
<div style="background: radial-gradient(at top left, black, darkcyan)"><span>corner</span></div>
<!--
Next to each side name, we can provide the length, how much to move
the center from it.
-->
<div style="background: radial-gradient(at top 30px left 30px, black, darkcyan)"><span>transitioned</span></div>
<!--
Or we can go with percentage.
-->
<div style="background: radial-gradient(at top 30% left 30%, black, darkcyan)"><span>percents</span></div>
<!--
We can provide more colors if needed.
-->
<div style="background: radial-gradient(at center, black, cyan, darkcyan)"><span>3 colors</span></div>
<!--
In the previous example, the darkcyan color is visible only on the corners.
If the box was rectangle and not square, it would be the farthest-corner.
We can specify the size of the gradient in pixels.
-->
<div style="background: radial-gradient(30px at center, black, cyan, darkcyan)"><span>size 30px</span></div>
<!--
Or we can use a keyword: closest-side, closest-corner,
farthest-side, farthest-corner. Defaults to farthest-corner.
-->
<div style="width: 200px; background: radial-gradient(closest-side at center, black, cyan, darkcyan)"><span>closest-side</span></div>
<div style="width: 200px; background: radial-gradient(farthest-side at center, black, cyan, darkcyan)"><span>farthest-side</span></div>
<div style="width: 200px; background: radial-gradient(closest-corner at center, black, cyan, darkcyan)"><span>closest-corner</span></div>
<div style="width: 200px; background: radial-gradient(farthest-corner at center, black, cyan, darkcyan)"><span>farthest-corner</span></div>
<!--
By default, the gradient has an ellipse shape,
but we can change it to circle.
-->
<div style="width: 200px; background: radial-gradient(ellipse closest-side at center, black, cyan, darkcyan)"><span>ellipse</span></div>
<div style="width: 200px; background: radial-gradient(circle closest-side at center, black, cyan, darkcyan)"><span>circle</span></div>
<!--
We can specify the stops for each color. Here we got a kind of ring.
-->
<div style="background: radial-gradient(black, darkcyan 10px, black 20px)"><span>ring</span></div>
<!--
If we wanted the gradient to repeat, we can do that easily by changing
the gradient function to repeating one.
-->
<div style="background: repeating-radial-gradient(black, darkcyan 10px, black 20px)"><span>repeating rings</span></div>
<!--
Finally, let's use the background image layers feature to put three
partially transparent radial gradients on top of each other.
-->
<div style="background:
radial-gradient(circle at bottom, #FF0000AA, transparent),
radial-gradient(circle at top left, #00FF00AA, transparent),
radial-gradient(circle at top right, #0000FFAA, transparent)
;"><span>layers</span></div>
<!--
As an alternative to using radial gradients, which radiate from the center point,
you can use conic gradients. By default they start at the top, and then build your
gradient by rotating clockwise around the center point.
-->
<div style="background: conic-gradient(black, darkcyan)"><span>conic</span></div>
<div style="background: conic-gradient(from 45deg, black, darkcyan)"><span>45deg</span></div>
<div style="background: conic-gradient(from 0.25turn, black, darkcyan)"><span>0.25turn</span></div>
<!--
We can modify the position of the center point.
-->
<div style="background: conic-gradient(from 0.25turn at 0% 0%, black, darkcyan)"><span>0% 0%</span></div>
<div style="background: conic-gradient(from 0.25turn at top left, black, darkcyan)"><span>top left</span></div>
<div style="background: conic-gradient(from 0.25turn at bottom right, black, darkcyan)"><span>bottom right</span></div>
<!--
Of course if needed, we can provide more colors to our conic gradient.
-->
<div style="background: conic-gradient(black, darkcyan, black)"><span>three colors</span></div>
<div style="background: conic-gradient(black, darkcyan, black, cyan, black)"><span>four colors</span></div>
</section>
<div id="logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc. --><path fill="white" d="M50.8 452.1L19.2 477.4c-2.1 1.7-4.7 2.6-7.4 2.6C5.3 480 0 474.7 0 468.2V192C0 86 86 0 192 0S384 86 384 192V468.2c0 6.5-5.3 11.8-11.8 11.8c-2.7 0-5.3-.9-7.4-2.6l-31.6-25.3c-3.3-2.7-7.5-4.1-11.8-4.1c-5.9 0-11.5 2.8-15 7.5l-37.6 50.1c-3 4-7.8 6.4-12.8 6.4s-9.8-2.4-12.8-6.4l-38.4-51.2c-3-4-7.8-6.4-12.8-6.4s-9.8 2.4-12.8 6.4l-38.4 51.2c-3 4-7.8 6.4-12.8 6.4s-9.8-2.4-12.8-6.4L77.6 455.5c-3.6-4.7-9.1-7.5-15-7.5c-4.3 0-8.4 1.5-11.7 4.1zM160 192c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32zm96 32c17.7 0 32-14.3 32-32s-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32z"/></svg>
</div>
<style>
#logo {
display: grid;
place-items: center;
border-radius: 50%;
background: radial-gradient(300px circle at bottom 80px left 80px, darkcyan, black);
filter: drop-shadow(0 0 5px black);
}
#logo svg {
height: 60%;
filter: drop-shadow(0 0 5px black);
}
</style>
</main>
@import "https://necolas.github.io/normalize.css/8.0.1/normalize.css";
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,300;0,400;0,600;0,700;0,900;1,400;1,600;1,700;1,900&display=swap');
* {
box-sizing: border-box;
}
body {
background-color: #092927;
color: white;
font-family: 'Montserrat', sans-serif;
}
main {
width: 100%;
margin: 2em auto;
@media (min-width: 400px) {
width: 80%;
}
}
p.intro {
color: white;
font-size: 0.9em;
text-align: justify;
}
h1 {
text-align: center;
font-weight: 900;
font-size: 2.5em;
}
.history {
display: flex;
flex-direction: row;
flex-wrap: wrap;
column-gap: 1em;
row-gap: 1.5em;
justify-content: center;
width: 100%;
div {
width: 100px;
height: 100px;
border: 1px solid white;
position: relative;
span {
display: inline-block;
font-size: 0.75em;
font-weight: 300;
padding: 0.5em;
background-color: #00000055;
position: absolute;
bottom: 0;
left: 0;
}
}
}
#current {
width: 300px;
height: 300px;
border: 1px solid white;
margin: 2em auto;
flex-grow: 0;
flex-shrink: 0;
}
#logo {
width: 300px;
height: 300px;
margin: 2em auto;
}
Also see: Tab Triggers