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 Linear Gradients</h1>
<p class="intro">CSS <code>linear-gradient()</code> and <code>repeating-linear-gradient()</code> functions allow to compute amazing gradients without need to use external graphics software. Get more details <a href="https://ideaspot.tv/css-linear-gradient-gradient-background-css/" target="_blank">here</a>.</p>
<section class="history">
<!--
To create a basic gradient, simply use linear-gradient function and provide
two colors. Here I am using the color names, but you can use everything
that is available for colors, so you can use hexadecimal values
or RGB etc.
-->
<div style="background: linear-gradient(black, darkcyan)"><span>default</span></div>
<!--
By default the gradient goes top to bottom. You can change it by setting
the quantity of turns. 0.25turn, 0.50turn etc.
-->
<div style="background: linear-gradient(0.25turn, black, darkcyan)"><span>0.25turn</span></div>
<div style="background: linear-gradient(0.50turn, black, darkcyan)"><span>0.50turn</span></div>
<div style="background: linear-gradient(0.75turn, black, darkcyan)"><span>0.75turn</span></div>
<div style="background: linear-gradient(1turn, black, darkcyan)"><span>1turn</span></div>
<!--
You can also specify the element sides and corners.
-->
<div style="background: linear-gradient(to left, black, darkcyan)"><span>to left</span></div>
<div style="background: linear-gradient(to right, black, darkcyan)"><span>to right</span></div>
<div style="background: linear-gradient(to bottom, black, darkcyan)"><span>to bottom</span></div><!--default-->
<div style="background: linear-gradient(to top, black, darkcyan)"><span>to top</span></div>
<div style="background: linear-gradient(to bottom right, black, darkcyan)"><span>to bottom right</span></div>
<!--
Alternatively, for more control, you can use degrees. 0 degrees is to top
and then as you increase it goes clockwise.
-->
<div style="background: linear-gradient(0deg, black, darkcyan)"><span>0deg</span></div><!-- to top; clockwise rotation -->
<div style="background: linear-gradient(45deg, black, darkcyan)"><span>45deg</span></div>
<div style="background: linear-gradient(-45deg, black, darkcyan)"><span>-45deg</span></div>
<!--
If we specify the gradient direction from left to right, then the first color
is set to be at the very left, and the second color at the very end.
And all between is a mix between those two colors. The mix goes proportionally
to distance between two colors, so in the middle, at 50% we have equal mix
between the left and right color.
-->
<div style="background: linear-gradient(to right, darkcyan, brown)"><span>default positioning</span></div>
<!--
We can provide the percentage value explicitly.
-->
<div style="background: linear-gradient(to right, darkcyan, 50%, brown)"><span>positioning 50%</span></div>
<!--
Or we can adjust. 25% would shift the mixing to the left, and 75% to the right.
-->
<div style="background: linear-gradient(to right, darkcyan, 25%, brown)"><span>positioning 25%</span></div>
<div style="background: linear-gradient(to right, darkcyan, 75%, brown)"><span>positioning 75%</span></div>
<!--
We can create a gradient between more than two colors.
Let's add cyan in between the two existing ones.
-->
<div style="background: linear-gradient(to right, black, cyan, darkcyan)"><span>more colors</span></div>
<!--
By default the middle color is put right in the middle, at 50%.
But we can adjust, so here it is at 25%. Or 75%.
-->
<div style="background: linear-gradient(to right, black, cyan 25%, darkcyan)"><span>positioning middle color (25%)</span></div>
<div style="background: linear-gradient(to right, black, cyan 75%, darkcyan)"><span>positioning middle color (75%)</span></div>
<!--
We can use this feature to control how wide each stripe is, and how
soft or sharp is the transition from one color to another.
-->
<div style="background: linear-gradient(to right, black 33%, black 33%, cyan 33%, cyan 67%, darkcyan 67%, darkcyan 100%)"><span>positioning each color</span></div>
<!--
For the last basic example, let's go max with the number of colors
and let's create a rainbow: red, orange, yellow, green, blue, indigo and violet.
-->
<div style="background: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)"><span>rainbow</span></div>
<!--
Finally, to make the stripes sharp, we will divide the 100% eqaully,
that is around 14% for each.
-->
<div style="background: linear-gradient(to right, red 14%, orange 14%, orange 28%, yellow 28%, yellow 42%, green 42%, green 58%, blue 58%, blue 72%, indigo 72%, indigo 86%, violet 86%)"><span>sharp stripes</span></div>
<!--
We can also create a gradient from a color to a transparency.
-->
<div style="background: linear-gradient(0deg, red, transparent);"><span>transparency</span></div>
<!--
Or we can use hexadecimal values for even more ALPHA channel control.
-->
<div style="background: linear-gradient(0deg, #FF0000AA, #FF000000);"><span>transparency</span></div>
<!--
Finally, we can use the CSS3 background layers feature to overlay
one gradient over the other. Here I will set three gradients - red, green and blue.
The red will start at 0degrees, the green at 120 degrees and blue at 240 degrees.
-->
<div style="background:
linear-gradient(0deg, #FF0000AA, #FF000000),
linear-gradient(120deg, #00FF00AA, #00FF0000),
linear-gradient(240deg, #0000FFAA, #0000FF00)
"><span>layers (deg)</span></div>
<!--
With these particular degree values, we can achieve similar effect by using
sides and corners instead of numbers.
-->
<div style="background:
linear-gradient(to top, #FF0000AA, #FF000000),
linear-gradient(to top right, #00FF00AA, #00FF0000),
linear-gradient(to top left, #0000FFAA, #00FF0000)
"><span>layers (sides)</span></div>
<!--
And finally something really amazing. We can use put a gradient layer
on top of an existing image background. Here let's add a mist over this
mountainy photoshoot.
-->
<div style="background:
linear-gradient(to bottom, mistyrose, transparent),
url('https://images.pexels.com/photos/2416864/pexels-photo-2416864.jpeg?auto=compress&cs=tinysrgb&w=600');
background-size: cover;
"><span>mist effect</span></div>
<!--
Let's use the gradient to create a single 2-color stripe at the left of our div.
-->
<div style="background: linear-gradient(to right, black, darkcyan 10px, black 20px)"><span>single stripe</span></div>
<!--
That created a single stripe. If we now wanted this stripe to be repeated,
to create a kind of a texture, we can use the repeating-linear-gradient function.
-->
<div style="background: repeating-linear-gradient(to right, black, darkcyan 10px, black 20px)"><span>repeated (px)</span></div>
<!--
Instead of pixels we can use percents.
-->
<div style="background: repeating-linear-gradient(to right, black, darkcyan 10%, black 20%)"><span>repeated (%)</span></div>
<!--
And finally, we can provide the exact values of color stops, in order to
make the strips sharp.
-->
<div style="background: repeating-linear-gradient(to right, black, black 10%, darkcyan 10%, darkcyan 20%)"><span>repeated (sharp)</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: linear-gradient(to top right, 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