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 id="form" class="form">
<div id="heading" class="glass glass--gradient glass--heading">
<span class="form-header">
<span class="form-icon"></span><span class="form-title">What would you like to build today?</span> </span>
<button class="form-close-button">✕</button>
</div>
<div id="input" class="glass">
<input type="text" placeholder="Type your request here">
</div>
</div>
:root{
--r: 20px;
--c: #171717;
--light-reflect: inset -5px 20px 2px -20px #fff, inset 5px -20px 2px -20px #fff;
--shadow-reflect: inset -19px 1px 2px -20px #000,inset 19px 1px 2px -20px #000, inset 19px 1px 2px -20px #000, inset -15px -26px 3px -30px #000;
--hh : 8rem;
}
body{
display:flex;
padding: 0 2rem;
color: var(--c);
font-family: sans-serif;
align-items:center;
justify-content:center;
min-height: 100svh;
background: radial-gradient(#ffffff54 2px, transparent 0) 0 0/40px 40px, radial-gradient(#00000026 2px, transparent 0) -1px 1px/40px 40px, radial-gradient(ellipse at 150% -50%, #6d788f, #fff);
}
.form{
position: relative;
--gap: .5rem;
max-width: 50rem;
flex: 1 1 auto;
height: var(--hh);
&.open{
height: calc(var(--hh) * 1.5 + var(--gap));
}
transition: 250ms ease all;
}
button{
appearance: none;
border: none;
background: none;
}
input{
appearance: none;
border: none;
background: none;
width: 100%;
height: 4rem;
padding: 0 2rem;
color: var(--c);
&:focus{
outline: none;
}
&::placeholder{
opacity: 0.3;
}
}
@keyframes text {
0% {
clip-path:polygon(0 0, 0 0, 0 100%, 0 100%)
}
100% {
clip-path:polygon(0 0, 100% 0, 100% 100%, 0 100%)
}
}
.form-title{
clip-path:polygon(0 0, 0 0, 0 100%, 0 100%);
animation: text linear 1s forwards;
animarion-delay: 1s;
}
@keyframes gradient {
0% {
background-size: 100%;
}
50% {
background-size: 150%;
}
100% {
background-size: 100%;
}
}
.glass{
position:relative;
display: flex;
align-items: center;
min-height: 4rem;
border-radius: var(--r);
border:none;
width: 100%;
background: rgba(#fff, 0.1);
backdrop-filter: blur(2px);
text-shadow: 0.25em 0.25em 1px #00000010;
--shadow-color: 0deg 0% 64%;
--shadow-elevation-high:
0.5px 1px 1.1px hsl(var(--shadow-color) / 0.28),
1.4px 3.1px 3.4px -0.4px hsl(var(--shadow-color) / 0.27),
2.5px 5.3px 5.9px -0.7px hsl(var(--shadow-color) / 0.25),
3.9px 8.4px 9.3px -1.1px hsl(var(--shadow-color) / 0.24),
6px 12.9px 14.3px -1.5px hsl(var(--shadow-color) / 0.23),
9px 19.5px 21.6px -1.8px hsl(var(--shadow-color) / 0.21),
13.4px 28.9px 32px -2.2px hsl(var(--shadow-color) / 0.2),
19.3px 41.7px 46.2px -2.6px hsl(var(--shadow-color) / 0.19),
27.1px 58.5px 64.8px -2.9px hsl(var(--shadow-color) / 0.17),
37.1px 80px 88.6px -3.3px hsl(var(--shadow-color) / 0.16);
--inner-light: inset 0 -6px 2px -5px #ffffff24, inset 0 -8px 3px -5px #ffffff3b, inset 0 -20px 10px -15px #ffffff5c, inset 7px 25px 10px -20px #ffffff5c;
--inner-shadow: inset -20px 5px 10px -20px #00000021, inset -40px 50px 7px -55px #00000021;
--external-light: 5px -30px 30px -20px #ffffff70, 5px 10px 30px -20px #ffffff70;
--default: var(--external-light), var(--shadow-elevation-high), var(--inner-light), var(--inner-shadow);
box-shadow:var( --default);
&:focus{
outline: none;
}
&--gradient{
background-position: center;
animation: gradient 10s linear infinite;
background: linear-gradient(45deg, #85d5e757, #7a9ed254, #ba6ac93d, #de54c217, #f86b2d4f);
}
&--heading{
font-size: 1.1rem;
&:before{
--i: 2px;
opacity:0.6;
}
&:after{
--i: 4px;
}
&:before,&:after{
content: '';
pointer-events: none;
position: absolute;
inset: var(--i);
border-radius: calc(var(--r) - var(--i));
box-shadow:var(--light-reflect), var(--shadow-reflect);
}
}
> * {
position:relative;
z-index: 1;
}
&:before{
--r: 20px;
--bp : 50px;
--s: calc(0% + var(--bp) + var(--r));
--e: calc(100% - var(--bp) - var(--r));
--z: calc(0% + var(--bp));
--h: calc(100% - var(--bp));
content: '';
position: absolute;
}
}
.form-header{
height: var(--hh);
padding: 0 2rem;
display: flex;
align-items: center;
gap: 2rem;
}
@keyframes icon {
0% {
rotate: 0deg;
scale: 0.8;
filter: hue-rotate(0deg)
}
50% {
rotate: 180deg;
scale: 1.2;
filter: hue-rotate(90deg)
}
100% {
rotate: 360deg;
scale: 0.8;
filter: hue-rotate(0deg)
}
}
.form-icon{
position: relative;
background: rgba(#fff,0.2);
display: block;
aspect-ratio: 1;
flex: 0 0;
border-radius: 50px;
height: 4rem;
box-shadow:var(--light-reflect), var(--shadow-reflect);
&:before{
animation: icon 5000ms cubic-bezier(0.22, 0.61, 0.36, 1) infinite;
content: '';
position: absolute;
inset:0;
background: url(https://cdn.discordapp.com/attachments/1050016262035619861/1159132066592591893/ia.png?ex=651ec55c&is=651d73dc&hm=162828e7743ded23e27d4fe81ee09e4df9f283e32a32bc322b99c116a4f307b7) center / 90% 90% no-repeat;
}
}
.form-close-button{
position: absolute;
color: var(--c);
background: rgba(#fff,0.3) ;
top: .75rem;
right: .75rem;
box-shadow:var(--light-reflect), var(--shadow-reflect);
display: grid;
place-content: center;
height: 1.5rem;
width: 1.5rem;
border-radius: 50px;
cursor: pointer;
visibility: hidden;
opacity: 0;
transition: 250ms ease opacity;
.open &{
visibility: visible;
opacity: 1;
}
}
[id='heading']{
transition: 250ms ease all;
.form:not(.open) &:hover{
scale:0.99;
filter: brightness(0.95);
}
.form:not(.open) &:active{
scale:0.98;
filter: brightness(0.8);
}
cursor: pointer;
}
[id='input']{
position: absolute;
top: 0;
left: 0;
z-index:-1;
height: var(--hh);
transition: 500ms ease all;
translate: 0 0;
opacity:0;
.open &{
translate: 0 calc(var(--hh) + var(--gap));
height: calc(var(--hh) / 2);
opacity:1;
z-index:2;
}
}
const form = document.getElementById("form");
const heading = document.getElementById("heading");
heading.onclick = (e) => {
form.classList.toggle('open')
}
Also see: Tab Triggers