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="container">
<header class="page-header cf">
<div class="logo">
<img src="https://dummyimage.com/150" alt="placeholder logo">
</div>
<h1>My Site Title</h1>
</header>
<!-- NAVIGATION-->
<div class="menu"> <a href="#" id="menu_button">Menu</a> </div>
<nav id="main_nav" role="navigation">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="retrieval.html">Retrieval Practice</a></li>
<li><a href="spaced.html">Spaced Practice</a></li>
<li><a href="elaboration.html">Elaboration</a></li>
<li><a href="interleaving.html">Interleaving</a></li>
<li><a href="concrete.html">Concrete Examples</a></li>
<li><a href="dualcoding.html">Dual Coding</a></li>
<li><a href="about.html">About</a></li>
</ul>
</nav>
<!--end main_nav -->
<main class="main-content">
<!-- Dummy Content -->
<p>When using this you may need to change the breakpoint when the nav changes. Remember both to change it in the CSS @media query and in the JavaScript in the doneResizing() function </p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum explicabo officia cumque, alias obcaecati natus, praesentium sapiente, eius blanditiis totam eaque molestiae consequatur? Nemo facere, doloribus iure commodi perspiciatis praesentium.</p>
<p><img src="http://placehold.it/800x800" alt="dummy image" /></p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Illum explicabo officia cumque, alias obcaecati natus, praesentium sapiente, eius blanditiis totam eaque molestiae consequatur? Nemo facere, doloribus iure commodi perspiciatis praesentium.</p>
</main>
<footer>
<p>© Chris Stein 2018</p>
</footer>
</div>
/* ============================
* Clearfix
* Modified from: http://nicolasgallagher.com/micro-clearfix-hack/
* If you already have a clearfix then you can ignore this.
* =============================*/
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
.cf:after {
content: " "; /* 1 */
display: table; /* 2 */
clear: both;
}
.cf:after {
clear: both;
}
/**
* For IE 6/7 only
* Include this rule to trigger hasLayout and contain floats.
*/
.cf {
*zoom: 1;
}
/* ============================
* NAVIGATION
* Modified from: http://webdesign.tutsplus.com/tutorials/htmlcss-tutorials/a-simple-responsive-mobile-first-navigation/
* =============================*/
#main_nav {
clear: both;
display: none;
/*hidden to start */
}
#main_nav ul {
list-style: none;
line-height: 1;
margin: 0;
padding: 0;
}
#main_nav li {
margin-bottom: 0;
}
#main_nav li a {
display: block;
color: #fff;
background-color: #555;
text-transform: uppercase;
padding: 0.625em;
/* 10px in ems is 10/16 */
text-decoration: none;
border-bottom: 1px solid #eee;
font-weight: 900;
}
#main_nav li a:hover {
color: #555;
background-color: #fff;
}
#main_nav li a:active {
color: #555;
background-color: #f90;
}
/* menu button */
.menu {
margin-top: 1em;
margin-bottom: 1em;
}
.menu a {
/* padding: 0.5em 0.625em; */
background-color: #555;
border-radius: 5px;
color: #fff;
text-decoration: none;
}
.menu a:hover {
color: #555;
background-color: #f90;
}
/* menu button */
.menu {
margin-top: 1em;
margin-bottom: 1em;
}
.menu a {
padding: 0.5em 0.625em;
background-color: #555;
border-radius: 5px;
color: #fff;
text-decoration: none;
}
.menu a:hover {
color: #555;
background-color: #f90;
}
/* ==========================
* Media Queries for Main Nav
* ========================== */
/* these don't have to be separate. We did so for two reasons:
1. Easy to copy and paste this into new design
2. Depending on your site you may need separate break points for the nav. You may want to see what width is needed to fit your nav horizontally without breaking and use that as the breakpoint.
It should also be noted that there is only one media query because this CSS moves the nav to the top where it can stay for all of the other sizes.
*/
@media (min-width: 1205px) {
/* hide the menu button */
.menu {
display: none;
}
#main_nav {
width: 100%;
display: block;
overflow: hidden;
/* should be the same as #main_nav li a background color above */
background-color: #555;
}
#main_nav li {
display: inline;
line-height: 1em;
}
#main_nav li a {
float: left;
padding: 0.9375em;
/* 10/16 and 15/16 */
border-bottom: none;
}
#main_nav li a.top {
display: none;
}
#footer_nav {
background-color: #fff;
}
}
/*
====================================
These styles are page specific and you would need to change depending on how your page is laid out.
====================================
*/
/* responsive images */
img, video{
width: auto;
height: auto;
max-width: 100%;
}
/* border-box model */
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
.page-header .logo{
float:left;
width: 25%;
}
.page-header h1{
float: left;
padding-left: 1em;
width: 70%;
/* set this to the height of your image if you ahve one */
line-height: 150px;
margin:0;
padding: 0;
}
.menu{
clear: both;
}
jQuery(document).ready(function ($) {
// Your jQuery code here, using $ to refer to jQuery.
/*
This is the code to slide the main navigation up and down.
*/
$('#menu_button').click(function (evt) {
console.log('evt', evt);
evt.preventDefault();
$('#main_nav').slideToggle();
}); //end menu_button
//this code taken from Sebastien on Stackoverflow: http://stackoverflow.com/questions/6461300/triggering-jquery-with-css-media-queries
//it's been rearranged slightly
//leave the lines below and then write your code in the doneResizing function below
doneResizing();
var id;
$(window).resize(function () {
clearTimeout(id);
id = setTimeout(doneResizing, 0);
});
function doneResizing() {
//this code requires that you have Modernizr included BEFORE this file. Here is modernizr: https://modernizr.com/
//the trick with min-width media queries is that you need to start from your largest and go down. In the else at the end you can write js for any size below your smallest min-width.
if (Modernizr.mq('screen and (min-width:1205px)')) {
$('#main_nav').show(); //make sure it is showing at larger sizes
}
else {
//Your code goes here for screens below 1205px in this example.
$('#main_nav').hide(); //make sure hiding at smaller sizes
}
console.log('resized');
} //end doneResizing
});
Also see: Tab Triggers