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="menu">
<h1> Pushki's Cafe </h1>
<h2 class="menuType"> Breakfast Menu </h2>
<div class="closed">
<h2> Sorry, the kitchen is currently closed </h2>
</div>
<div class="options">
<article>
<div class="title">
<span class="menuItem">Item One</span>
<span class="price">£17.99</span>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem rerum ratione illo tempore veritatis earum fuga, explicabo, nulla sunt, expedita libero. Eveniet porro ea labore, non excepturi quaerat totam impedit.
</p>
</article>
<article>
<div class="title">
<span class="menuItem">Item One</span>
<span class="price">£17.99</span>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem rerum ratione illo tempore veritatis earum fuga, explicabo, nulla sunt, expedita libero. Eveniet porro ea labore, non excepturi quaerat totam impedit.
</p>
</article>
<article>
<div class="title">
<span class="menuItem">Item One</span>
<span class="price">£17.99</span>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem rerum ratione illo tempore veritatis earum fuga, explicabo, nulla sunt, expedita libero. Eveniet porro ea labore, non excepturi quaerat totam impedit.
</p>
</article>
<article>
<div class="title">
<span class="menuItem">Item One</span>
<span class="price">£17.99</span>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem rerum ratione illo tempore veritatis earum fuga, explicabo, nulla sunt, expedita libero. Eveniet porro ea labore, non excepturi quaerat totam impedit.
</p>
</article>
<article>
<div class="title">
<span class="menuItem">Item One</span>
<span class="price">£17.99</span>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem rerum ratione illo tempore veritatis earum fuga, explicabo, nulla sunt, expedita libero. Eveniet porro ea labore, non excepturi quaerat totam impedit.
</p>
</article>
<article>
<div class="title">
<span class="menuItem">Item One</span>
<span class="price">£17.99</span>
</div>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem rerum ratione illo tempore veritatis earum fuga, explicabo, nulla sunt, expedita libero. Eveniet porro ea labore, non excepturi quaerat totam impedit.
</p>
</article>
</div>
</div>
body {
font-family:'Source Sans Pro';
}
h1{
font-size: 40px;
text-align: center;
font-weight: bold;
padding-bottom: 3%;
}
h2{
text-align: center;
font-weight: bold;
padding-bottom: 2%;
}
.closed{
visibility:hidden;
}
.options{
visibility: visible;
}
.menu {
position:relative;
margin:100px auto;
width:90%;
max-width:1024px;
}
.title {
position:relative;
padding:10px;
font-size:19px;
font-weight:700;
}
.title span {
position:relative;
background:#fff;
padding:0 15px 0 0;
}
.title .price {
float:right;
padding:0 0 0 15px;
}
.title:before {
position:absolute;
top:50%;
left:10px;
right:10px;
height:1px;
border-top:2px dotted rgba(0,0,0,0.3);
display:block;
content:'';
}
@media (min-width:420px) {
article {
width:50%;
float:left;
}
}
article p {
margin:0;
padding:0 10px 10px;
}
// In this project, you will update the menu of the restaraunt Pushki's Cafe depending on the time of day
// The restaurant serves customers breakfast, lunch, and dinner, and the kitchen takes breaks in between to clean and prepare the food options for the next meal
// Breakfast is served from 6:00 AM to 10:00 AM, and then the kitchen closes for 1 hour to prepare for lunch
// Lunch is served from 11:00 AM to 3:00 PM and then the kitchen closes for 1 hour to prepare for dinner
// Dinner is served from 4:00 PM to 10:00 PM, then the kitchen closes for the day.
// You can see the menu for Pushki's Cafe in the result pane. The menu name under the title Pushki's Cafe will change with the menu items
// Depending on the current time, display the correct menu by replacing the h2 indicating which meal is currently being served, and which dishes are available
// Implement a series of conditional statements to check the time, and adjust the menu accordingly
// For example, if the current time is between 4:00 and 10:00 PM, the page should display "Dinner Menu" and the items should be replaced with the elements of the dinner menu array instead of "item one"
// If the kitchen is closed, remove the menu from the page by disabling the view of the "options" div and displaying the div with the class "closed"
// When the kitchen opens again, disable the display of the "closed" div and redisplay the "options" div
// Below are the arrays containing the dishes offered for each meal:
let breakfastMenu = ["Chicken and Waffles","Pancake Platter","Breakfast Feast","Garden Omelette and Fruit","French Toast","Shrimp & Grits"];
let lunchMenu = ["Shrimp Mac & Cheese","Steak Quesadilla","Smoked Turkey & Brie Panini","Walnut Spinach Cranberry Salad","Chicken Pot Pie","Rueben Croissant"];
let dinnerMenu = ["Muffaletta: Half or Whole","Crawfish Etoufée","Stuffed Shrimp","Blackened Salmon","Jalepeño Bacon Burger","Red Beans & Rice w/ Sausage"];
// First store all of the HTML elements you will need to access to complete the project (hint: 4 variables needed)
// (hint: you only need 1 variable to store all 6 HTML menu items that will be replaced. Think about which method selects all of the elements matching the class)
// Note: only the spans containing the text 'Item One' will be replaced with the names of the dishes; don't worry about the lorem ipsum item description or the item's price
// Next create a time object representing the current time, and implement conditional statements for the times given
// Remember that during the time the kitchen is cleaning and prepping for the next meal, the menu should not be displayed on the site,
// instead the div stating "Sorry, the kitchen is currently closed" should be displayed, and then removed when the kitchen reopens and replaced with the next menu
// Within the conditional statements for the different meal's time windows, replace the menu items with the appropritate array's elements
// Note that you'll probably only edit this codepen during certain hours, so whichever function is currently executing depending on the current time can be used to test that your other functions work by replacing the code temporarily to make the function execute since it will only execute at a specific time otherwise
Also see: Tab Triggers