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="content">
<article class="wrapper" id="card1">
<h1 class="pageTitle">Responsive Material Layout</h1>
<h2 class="pageSubTitle">Responsive, Parallax and material</h2>
<a class="link" id="fb"><h3>Link 1
</h3></a>
<a class="link"><h3>Link 2
</h3></a>
<a class="link"><h3>Link 3
</h3></a>
<a class="link"><h3>Link 4
</h3></a>
<a class="link"><h3>Link 5
</h3></a>
</article>
<article class="wrapper">
<header>
<h1 class="pageTitle">A little bit of info</h1>
<h2 class="pageSubTitle">Add links with the fab button, resize your browser & scroll !</h2>
</header>
<section>
<p>I highly suggest to download source files before correcting some layout problems. Most of them (link titles, excessive margins above and beneath card titles, no full display of the 'phone' layout) are due to rendering here in Codepen. I don't get them on Firefox or Chrome. Even Internet Explorer shows things properly. This may be caused by incorrect loaded scripts, as I mostly done it in Dreamweaver.</p>
<p>The intial goal of this pen is to create a Material startpage and this is just the beginning. Layout isn't perfect yet (proper animation when the fab disappear) and I hope solutions are gonna come.
Beside the layout, I'll still have a lot of things to work out : Modal window on fab click, ASP/PHP request to manage existing/new shortcut, sub-FAB buttons to access bookmarks/history/plugins, automatic thumbnail site retrieving based on link...
I will take the time needed, as I'm just learning all of these languages, and it's not a full time job !</p>
</section>
</article>
<article class="wrapper">
<header>
<h2 class="pageSubTitle">A card to showcase the parallax effect</h2>
</header>
<section>
<p>And I'll just add another paragraph for the parallax effect : Vivamus tincidunt tortor et elementum tempor. Morbi consequat sapien nec maximus interdum. Nullam gravida mauris sed hendrerit viverra. Quisque ultrices malesuada leo in auctor. Aliquam
erat volutpat. Nunc et elit ac ante mattis vehicula eu sed ex. Integer dapibus volutpat gravida. Nulla sodales turpis accumsan eros suscipit, viverra elementum erat fringilla. Nunc mollis sit amet ex ut commodo. Mauris a pharetra ipsum, id condimentum
lorem. Duis sed volutpat elit. Nullam aliquam libero ipsum, vitae elementum est mattis in. Aliquam convallis orci sit amet mi pellentesque interdum. Etiam aliquet, sem non eleifend fermentum, ipsum arcu congue purus, quis interdum nisi orci id
nisl. Nullam feugiat facilisis felis quis dapibus.</p>
<p>Duis consequat, nunc vel bibendum tristique, eros leo ullamcorper tellus, et molestie mi ex ut mauris. Quisque sit amet enim augue. Mauris efficitur metus lorem, eu molestie urna elementum sed. Nam vel sodales enim. Sed suscipit bibendum cursus.
Nulla id tempor velit, aliquam sodales odio. Duis sit amet magna leo.</p>
<p>Vestibulum efficitur nunc vitae lacus consectetur, vitae convallis ex euismod. Maecenas ultrices massa sit amet libero euismod facilisis. Morbi non nulla nec ex suscipit bibendum eget a urna. Donec ullamcorper, nisl vitae congue dapibus, felis ex
tristique elit, at condimentum quam leo id mi. Fusce quis ligula consequat, gravida erat ullamcorper, semper nunc. Nullam ac augue justo. Pellentesque augue mi, porttitor non tempus quis, efficitur id sem. Duis enim arcu, laoreet at malesuada
ut, tempor in eros. Sed blandit eros eget erat dignissim tincidunt. Donec risus diam, bibendum nec diam id, faucibus ultrices lectus. Praesent ornare mollis tellus, sed tempus quam laoreet at. Phasellus venenatis lacus risus, vitae pharetra magna
malesuada vel. Mauris imperdiet congue ex, nec dictum enim facilisis vel.</p>
</section>
</article>
</div>
<div class="para">
<aside id="fab-wrap">
<div id="fab">
<div id="fab-action">
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
<path d="M19 13h-6v6h-2v-6h-6v-2h6v-6h2v6h6v2z"/>
</svg>
</div>
</div>
</aside>
<div class="background">
<div id='header'>
</div>
</div>
</div>
<script src='https://codepen.io/assets/libs/fullpage/jquery.js'></script>
<script src="js/index.js"></script>
<script src="js/modernizr.js"></script>
@import url(https://fonts.googleapis.com/css?family=Roboto:400,100,300,500,700,900);
body {
font-family: 'Roboto', sans-serif;
font-size: 14px;
font-weight: 300;
line-height: 1.6em;
letter-spacing: 1px;
color: #555;
}
a {
text-decoration: none;
}
a:active {
color: #555;
}
a:visited {
color: #555;
}
a:hover {
color: #555;
}
p {
margin-bottom: 1.6em;
}
header {
margin: 0 0 20px 0;
border-bottom: solid 1px #e0e0e0;
}
.pageTitle,
.pageSubTitle {
font-family: 'Roboto', sans-serif;
text-transform: uppercase;
color: #777;
}
.pageTitle {
color: #ff7600;
}
.pageTitle {
font-size: 31px;
font-weight: 700;
line-height: 37px;
}
.pageSubTitle {
font-size: 1.4em;
font-weight: 300;
margin-bottom: 1em;
}
.para {
position: fixed ;
width: 100%;
top: 0;
height: 300%;
;
}
.background {
position: fixed;
z-index: -1;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 100%;
height: 300%;
background-color: #f0f0f0;
background-size: 100% auto;
}
.content {
width: 60%;
margin-top: 150px;
margin-right: auto;
margin-left: auto;
}
#header {
height: 200px;
-webkit-transform: scaleX(-1);
-moz-transform: scaleX(-1);
-o-transform: scaleX(-1);
transform: scaleX(-1);
background-image: url('https://3.bp.blogspot.com/-a4JOdrhZBXI/UcTNSycowvI/AAAAAAAAAtk/9brebqGwNiw/s1600/Google-Now-Backgrounds-Tahoe-Dawn.jpg');
background-position: center center;
background-size: cover;
filter: FlipH;
-ms-filter: 'FlipH';
}
#fab-wrap {
position: absolute;
top: 200px;
height: 56px;
right: 0;
width: 13%;
-webkit-transition: all 600ms cubic-bezier((.77, 0, .175, 1));
-webkit-transition: opacity .3s;
-o-transition: all 600ms cubic-bezier((.77, 0, .175, 1));
-o-transition: opacity .3s;
transition: all 600ms cubic-bezier((.77, 0, .175, 1));
transition: opacity .3s;
}
#fab {
display: flex;
width: 56px;
height: 56px;
margin-right: auto;
margin-left: auto;
cursor: pointer;
-webkit-transition: background-color .2s;
-o-transition: background-color .2s;
transition: background-color .2s;
border-radius: 50%;
background-color: #fb5e0b;
box-shadow: 0 3px 3px rgba(0, 0, 0, .17);
justify-content: center;
transform: translate(0%, -50%);
}
#fab:hover {
-webkit-box-shadow: 0 5px 4px rgba(0, 0, 0, .4);
box-shadow: 0 3px 4px rgba(0, 0, 0, .4);
}
#fab:active {
background-color: #fb6e21;
}
#fab-action {
z-index: 3;
padding-top: 16px;
}
.hidden {
opacity: 0;
}
svg {
transform: scale(1.25);
fill: #fdfdfd;
}
.wrapper {
position: relative;
display: block;
width: auto;
margin-bottom: 20px;
padding: 25px;
padding-left: 30px;
background: #fff;
box-shadow: 0 3px 3px 1px rgba(0, 0, 0, .15);
}
.center {
display: flex;
flex-wrap: wrap;
}
.link {
display: inline-block;
width: 18%;
height: 150px;
margin: .4vw;
margin-bottom: 15px;
cursor: pointer;
transition: all .2s cubic-bezier(.4, 0, .2, 1);
border-radius: .125em;
background-color: rgba(239, 239, 239, 1.00);
box-shadow: 0 3px 3px rgba(126, 111, 111, .2);
-webkit-tap-highlight-color: transparent;
}
.link:hover {
box-shadow: 0 3px 4px rgba(126, 111, 111, .5);
}
.link:active {
background-color: rgba(220, 220, 220, 1.00);
}
h3 {
font-family: Roboto;
font-size: 1em;
font-weight: 700;
position: relative;
bottom: 0;
padding: 7px 0;
text-align: left;
text-indent: 10px;
letter-spacing: .05em;
text-transform: uppercase;
background-color: rgba(255, 255, 255, .70);
}
@media screen and (max-width: 1280px) {
.link {
width: 23%;
}
.content {
width: 70%;
}
}
@media screen and (max-width: 1060px) {
.link {
width: 31%;
}
.content {
width: 75%;
}
}
@media screen and (max-width: 800px) {
.link {
width: 48%;
}
}
@media screen and (max-width: 600px) {
.content {
width: 94%;
}
#fab-wrap {
top: 150px;
right: 25px;
}
.wrapper {
padding-top: 55px;
}
}
@media screen and (max-width: 480px) {
.content {
width: 100%;
height: 200px;
}
.wrapper {
margin-bottom: 5px;
}
.link {
width: 100%;
}
}
//Parallax header
$(window).scroll(function(e) {
parallax();
});
$(window).trigger("scroll")
function parallax() {
var scrolled = $(window).scrollTop();
$('.background').css('top', -(scrolled * 0.5) + 'px');
}
//Hide Fab on scroll
$(window).scroll(function() {
var wrapper = $('#fab');
if ($(window).scrollTop() > 20) {
if ($(window).width() > 600) {
wrapper.addClass('hidden');
}
} else {
wrapper.removeClass('hidden');
}
});
$('#fab').on("click", function() {
var link = " <a class='link'><h3>Added link</h3></a>";
$("#card1").append(link);
});
Also see: Tab Triggers