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.
<!-- <script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script> -->
<!-- Navigation -->
<nav id="navbar">
<header>CSS Grid Layout Module</header>
<ul>
<a class="nav-link" href="#Grid_Layout" rel="internal"><li>Grid Layout</li></a>
<a class="nav-link" href="#Browser_Support" rel="internal"><li>Browser Support</li></a>
<a class="nav-link" href="#Grid_Elements" rel="internal"><li>Grid Elements</li></a>
<a class="nav-link" href="#Display_Property" rel="internal"><li>Display Property</li></a>
<a class="nav-link" href="#Grid_Columns" rel="internal"><li>Grid Columns</li></a>
<a class="nav-link" href="#Grid_Rows" rel="internal"><li>Grid Rows</li></a>
<a class="nav-link" href="#Grid_Gaps" rel="internal"><li>Grid Gaps</li></a>
<a class="nav-link" href="#Grid_Lines" rel="internal"><li>Grid Lines</li></a>
<a class="nav-link" href="#The_Justify_Content_Property" rel="internal">
<li>The Justify Content Property</li>
</a>
<a class="nav-link" href="#The_Align_Content_Property" rel="internal"><li>The Align Content Property</li></a>
<a class="nav-link" href="#Reference" rel="internal"><li>Reference</li></a>
</ul>
</nav>
<!-- /Navigation -->
<!--Main Content-->
<main id="main-doc">
<section class="main-section" id="Grid_Layout">
<header>Grid Layout</header>
<article>
<p>The CSS Grid Layout Module offers a grid-based layout system, with rows and columns, making it easier to design web pages without having to use floats and positioning.</p>
</article>
</section>
<section class="main-section" id="Browser_Support">
<header>Browser Support</header>
<article>
<p>The grid properties are supported in all modern browsers.</p>
<div class="grid-container">
<div class="browser">Chrome</div>
<div class="browser">IE / Edge</div>
<div class="browser">Firefox</div>
<div class="browser">Safari</div>
<div class="browser">Opera</div>
<div class="version-number">57.0</div>
<div class="version-number">16.0</div>
<div class="version-number">52.0</div>
<div class="version-number">10</div>
<div class="version-number">44</div>
</div>
</artice>
</section>
<section class="main-section" id="Grid_Elements">
<header>Grid Elements</header>
<article>
<p>A grid layout consists of a parent element, with one or more child elements.</p>
<code>
<div class="grid-container"><br>
<div class="grid-item">1</div><br>
<div class="grid-item">2</div><br>
<div class="grid-item">3</div><br>
<div class="grid-item">4</div><br>
</div>
</div>
</code>
</article>
</section>
<section class="main-section" id="Display_Property">
<header>Display Property</header>
<article>
An HTML element becomes a grid container by setting the <span>display</span> property to <span>grid</span> or <span>inline-grid</span>.
<code>.grid-container {<br>
display: grid;<br>
}</code>
<code>.grid-container {<br>
display: inline-grid;<br>
}</code>
<p>To make an HTML element behave as a grid container, you have to set the display property to grid or inline-grid.</p>
<p>Grid containers consist of grid items, placed inside columns and rows.</p>
</article>
</section>
<section class="main-section" id="Grid_Columns">
<header>Grid Columns</header>
<article>
<p>The vertical line of grid items are called columns.</p>
<p>The <span>grid-template-columns</span> property defines the number of columns in your grid layout, and it can define the width of each column.</p>
<p>The value is a space-separated-list, where each value defines the length of the respective column.</p>
<p>If you want your grid layout to contain 4 columns, specify the width of the 4 columns, or "auto" if all columns should have the same width.</p>
<p>Example: a 4 column grid.</p>
<code>.grid-container {<br>
display: grid;
grid-template-columns: auto auto auto auto;<br>
}</code>
</article>
</section>
<section class="main-section" id="Grid_Rows">
<header>Grid Rows</header>
<article>
<p>The horizontal line of grid items are called rows.</p>
<p>The grid-template-rows property defines the height of each row.</p>
<p>The value is a space-separated-list, where each value defines the the height of the respective row:</p>
<code>.grid-container {<br>
display: grid;<br>
grid-template-rows: 80px 200px;<br>
}</code
</article>
</section>
<section class="main-section" id="Grid_Gaps">
<header>Grid Gaps</header>
<article>
<p> You can adjust the gap size by using one of the following properties:</p>
<ul>
<li><span>grid-column-gap</span></li>
<li><span>grid-row-gap</span></li>
<li><span>grid-gap</span></li>
</ul>
</article>
</section>
<section class="main-section" id="Grid_Lines">
<header>Grid Lines</header>
<article>
<p>The line between columns are called column lines.</p>
<p>The line between rows are called row lines.</p>
<p>Refer to line numbers when placing a grid item in a grid container. For example, place a grid item at column line 1, and let it end on column line 3:</p>
<code>
.item1 {<br>
grid-column-start: 1;<br>
grid-column-end: 3;<br>
}
</code>
</article>
</section>
<section class="main-section" id="The_Justify_Content_Property">
<header>The Justify Content Property</header>
<article>
<p>The <span>justify-content</span> property is used to <em>horizontally</em> align the whole grid inside the container.</p>
<p>The <span>justify-content</span> property can be:</p>
<ul>
<li><span>space-evenly</span></li>
<li><span>space-around</span></li>
<li><span>space-between</span></li>
<li><span>center</span></li>
<li><span>start</span></li>
<li><span>end</span></li>
</ul>
<code>
.grid-container {<br>
display: grid;<br>
justify-content: space-evenly;<br>
}
</code>
</article>
</section>
<section class="main-section" id="The_Align_Content_Property">
<header>The Align Content Property</header>
<article>
<p>The align-content property is used to <em>vertically</em> align the whole grid inside the container.</p>
<p>The <span>align-content</span> property can be:</p>
<ul>
<li><span>space-evenly</span></li>
<li><span>space-around</span></li>
<li><span>space-between</span></li>
<li><span>center</span></li>
<li><span>start</span></li>
<li><span>end</span></li>
</ul>
<code>
.grid-container {<br>
display: grid;<br>
align-content: space-evenly;<br>
}
</code>
</article>
<section class="main-section" id="Reference">
<header>Reference</header>
<article>
<li>All the documentation in this page is taken from <a href="https://www.w3schools.com/" target="_blank">W3schools.</a>
</article>
</section>
<footer id="footer">
<p>Coded by Francesca Jenkins | freeCodeCamp 2018</p>
</footer>
</main>
html,body{
min-width:290px;
color: #4d4e53;
background-color: #ffffff;
font-family: 'Open Sans',Arial,sans-serif;
line-height: 1.5;
}
#navbar{
position:fixed;
min-width:290px;
top:0px;
left:0px;
width:300px;
height:100%;
border-right:solid;
border-color:#0D47A1;
background-color: #D3EAFC;
}
header{
color: #0D47A1;
font-size: 25px;
margin:10px;
text-align:center;
/* font-size:1.8em; */
font-weight:thin;
}
#main-doc header{
text-align:left;
margin:0px;
}
#navbar ul{
height:88%;
overflow-y:auto;
overflow-x:hidden;
}
#navbar li{
color: #0D47A1;
border:1px solid;
border-bottom-width:0px;
padding:8px;
padding-left:45px;
list-style: none;
position:relative;
left:-50px;
width:100%;
}
#navbar a{
color: #4d4e53;
text-decoration:none;
cursor:pointer;
}
#main-doc{
position: absolute;
margin-left:310px;
padding:20px;
margin-bottom:110px;
}
section article{
color: #4d4e53;
margin:15px 100px 65px 0;
font-size:0.96em;
}
section li {
margin:15px 0px 0px 20px;
}
.grid-container {
font-size: 1em;
max-width: 75%;
display: grid;
grid-template: repeat(2, auto) / repeat(5, auto);
grid-gap: 3px;
}
.browser{
border: 1px solid #0D47A1;
border-radius: 2px;
text-align: center;
color: #0D47A1;
background-color: #D3EAFC;
}
.version-number {
border: 1px solid #0D47A1;
border-radius: 2px;
text-align: center;
}
code {
display: block;
background: #0D47A1;
border-radius: 3px;
color: white;
font-size: 1em;
padding: 10px;
max-width: 500px;
margin: 20px;
}
span {
font-family: monospace;
font-size: 1.2em;
background-color: #ECEFF1;
}
#footer {
font-size: 12px;
text-align: center;
}
@media only screen and (max-width: 815px) {
/* For mobile phones: */
#navbar ul{
border:1px solid;
height:207px;
}
#navbar{
position:absolute;
top:0;
padding:0;
margin: 0;
width:100%;
max-height:275px;
border:none;
z-index:1;
border-bottom:2px solid;
}
#main-doc{
position: relative;
margin-left:0px;
margin-top:270px;
}
#main-doc section {
/* padding-top: 240px; */
}
.grid-container {
max-width: 100%;
}
}
@media only screen and (max-width: 400px) {
#main-doc{
margin-left:-10px;
}
.grid-container {
max-width: 100%;
}
code{
margin-left:-20px;
width:100%;
padding:15px;
padding-left:10px;
padding-right:45px;
min-width:233px;
}
}
Also see: Tab Triggers