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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<!-- Build a Pen with a mega menu -->
<header>
<h1>Burger Joint</h1>
<h1 id="menu_toggle" class="material-icons" style="font-size: 3.2em; cursor: pointer;">
menu</h1>
<nav id="navigation">
<div class="div1">
<h2>Menu</h2>
</div>
<div class="div2">
<div id="menu_nav--burgers">
<p>Burgers</p>
<ul>
<li>The Big Cheese</li>
<li>The Big Veg</li>
<li>The Double Big-Big</li>
<li>The Big Boss</li>
<li>The Little Big</li>
</ul>
</div>
<div id="menu_nav--fries">
<p>Fries</p>
<ul>
<li>Classic Fries</li>
<li>Seasoned Fries</li>
<li>Curly Fries</li>
<li>Tater Tots</li>
</ul>
</div>
<div id="menu_nav--salads">
<p>Salads</p>
<ul>
<li>The Big 'Burg</li>
<li>The Big Ceasar</li>
<li>The Giant Garden</li>
</ul>
</div>
<div id="menu_nav--shakes">
<p>Shakes</p>
<ul>
<li>Big Vanilla</li>
<li>Big Chocolate</li>
<li>Big Strawberry</li>
<li>Big Cookies & Creme</li>
</ul>
</div>
</div>
<div class="div3">
<div id="location_nav">
<p>Locations & Hours</p>
<ul>
<li>New York City</li>
<li>Chicago</li>
<li>San Francisco</li>
<li>Los Angeles</li>
<li>Philadelphia</li>
<li>Toronto</li>
<li>Vancouver</li>
</ul>
</div>
<div id="takeout_nav">
<p>Takeout & Delivery</p>
</div>
<div id="catering__nav">
<p>Catering</p>
</div>
<div id="join-club_nav">
<p>Join the Big Burger Club</p>
</div>
</div>
</nav>
</header>
<main>
<div id="sec1">
<!-- Image from unsplash -->
<img src="https://images.unsplash.com/photo-1586190848861-99aa4a171e90?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=580&q=80" alt="An image of burger">
<div>
<h1>Lorem ipsum dolor sit amet, consectetur</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus ad amet dolorem dolorum ex facilis hic impedit molestias, nemo nostrum pariatur quam quis ut. Deserunt fuga minus molestiae nesciunt totam!</p>
</div>
</div>
<div id="sec2">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Animi architecto, commodi deserunt enim et
excepturi facilis fuga laborum nemo nesciunt nihil quas quasi ratione saepe velit vitae voluptates? Sunt,
voluptate? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Architecto at debitis earum facere fugit quibusdam! Alias asperiores dolorem, esse ex excepturi fuga id labore minus neque nobis quam suscipit voluptates.</p>
<p>Assumenda corporis fugit harum, iste officiis perspiciatis quasi sapiente voluptate? Amet consequatur
deserunt dolorum eius explloremicabo facere facilis harum, mollitia necessitatibus nesciunt nobis quidem
reprehenderit similique sint ullam ut velit.</p>
<p>Aperiam autem delectus deserunt doloribus et ex expedita facere fuga hic incidunt ipsa itaque minima modi
neque odio officia provident, ratione reprehenderit repudiandae sint sit sunt suscipit tenetur vel
vitae Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda dolorum laborum, libero nostrum pariatur perspiciatis saepe tempore? Corporis deleniti, eaque illum pariatur tempore tenetur ullam! Aperiam deserunt est fugiat inventore.!</p>
<p>Ad architecto deleniti dignissimos distinctio esse et eveniet explicabo ipsa iure nihil recusandae totam vel, Lorem ipsum dolor sit amet, consectetur adipisicing elit. A ad autem consectetur cum exercitationem fuga id iusto, laudantium minima necessitatibus pariatur reiciendis, temporibus vitae! Molestiae nihil officiis quaerat quos veniam? Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus accusantium ad architecto autem, dicta dolorem doloribus facere facilis fuga illum molestiae natus nisi nulla perferendis perspiciatis, quaerat quo sint soluta.
voluptatem! Assumenda cupiditate, enim fugit officia quisquam soluta tenetur. Asperiores at doloremque
officiis provident voluptatibus?</p>
<p>Assumenda autem blanditiis, consectetur delectus dolorum eius eligendi error harum impedit labore laudantium
maxime minus nemo neque nulla numquam quis, recusandae rem unde ut vel vitae voluptates voluptatum.
Consectetur, nesciunt?</p>
</div>
</main>
@charset "UTF-8";
:root {
font-size: 20px;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
position: relative;
font-family: "Poppins", sans-serif;
}
li {
list-style-type: none;
}
header {
width: 100%;
height: 5em;
padding: 0.5em 4em;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
justify-content: space-between;
align-items: center;
}
header > h1 {
display: inline-block;
}
.menu-open header {
padding: 0.5em 4em 0 4em;
min-height: 100vh;
height: auto;
}
#navigation {
width: 100%;
height: 0;
overflow: hidden;
padding: 0;
background: #fffa4d;
color: black;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: 1fr;
grid-column-gap: 10px;
grid-row-gap: 10px;
border-top-left-radius: 1em;
border-top-right-radius: 1em;
opacity: 0;
transition: all 0.5s ease;
border-top: 2px solid #000;
border-left: 2px solid #000;
border-right: 2px solid #000;
}
#navigation > div {
padding: 0.5em;
}
#navigation > div li {
transition: margin-left 0.3s ease;
cursor: pointer;
}
#navigation > div li:before {
content: "→";
position: absolute;
right: 100%;
opacity: 0;
transition: opacity 0.3s ease;
}
#navigation > div li:hover {
margin-left: 0.5em;
}
#navigation > div li:hover:before {
opacity: 1;
}
#navigation p {
font-size: 1.1em;
font-weight: 700;
}
#navigation > .div1 {
grid-area: 1/1/2/2;
}
#navigation > .div1 h2 {
font-size: 6em;
}
#navigation > .div2 {
grid-area: 1/2/2/4;
display: flex;
flex-wrap: wrap;
align-content: flex-start;
row-gap: 1em;
column-gap: 0.5em;
}
#navigation > .div2 div {
width: calc(50% - 0.5em);
}
#navigation > .div3 {
grid-area: 1/4/2/5;
border-left: 0.2em solid #000;
}
#navigation > .div3 div {
margin: 1em 0;
}
#navigation > .div3 div:first-child {
margin-top: 0;
}
#navigation > .div3 div:last-child {
margin-bottom: 0;
}
#navigation > .div3 #takeout_nav,
#navigation > .div3 #catering__nav,
#navigation > .div3 #join-club_nav {
cursor: pointer;
}
.menu-open #navigation {
height: calc(100vh + 4.5em);
padding: 1em 0;
opacity: 1;
transition: all 0.5s ease;
}
body {
background-color: #fff91a;
}
body.menu-open {
height: calc(100vh + 15em);
}
main {
padding-inline: 4em !important;
}
#sec1 {
height: calc(100vh - 5em);
opacity: 1;
transition: all 0.5s 0.4s ease;
display: flex;
align-items: center;
justify-content: space-between;
}
#sec1 img {
width: 40%;
}
#sec1 div {
width: 50%;
}
#sec1 div h1 {
font-size: 3em;
}
.menu-open #sec1 {
opacity: 0;
transition: all 1s ease;
}
#sec2 p {
padding-left: 10em;
margin: 1.5em 0;
}
let flag = true;
$("#menu_toggle").click(function () {
$("body").toggleClass("menu-open");
if (flag === true) {
$("#menu_toggle").text("close");
$(window).lockscroll(true);
flag = false;
} else {
$("#menu_toggle").text("menu");
$(window).lockscroll(false);
flag = true;
}
});
Also see: Tab Triggers