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.
<!-- LAYOUT CONTAINER -->
<!-- Simple header with fixed tabs. -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header
mdl-layout--fixed-tabs">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">Kaptain Kitty</span>
</div>
<!-- Tabs -->
<div class="mdl-layout__tab-bar mdl-js-ripple-effect">
<a href="#fixed-tab-1" class="mdl-layout__tab is-active">About</a>
<a href="#fixed-tab-2" class="mdl-layout__tab">Learn</a>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">Kaptain Kitty</span>
<div class="avatar">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/cat.jpg" alt="Kaptain Kitty" class="avatar-img">
</div>
<!-- /.avatar -->
<div class="drawer-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aspernatur officiis animi, soluta ab deserunt dolore fugit voluptatem laboriosam, magni. Eligendi quia quasi qui cupiditate optio fugit vel, suscipit harum illum.
</div>
<!-- /.drawer-text -->
</div>
<!-- /.mdl-layout__drawer -->
<main class="mdl-layout__content">
<div class="mdl-layout__tab-panel is-active" id="fixed-tab-1">
<div class="page-content">
<!-- Your content goes here -->
<!-- Hero section -->
<div class="hero-section">
<div class="hero-text mdl-typography--text-center">
<h1 class="mdl-typography--display-2">I'm Kaptain Kitty</h1>
<p class="mdl-typography--display-1">
I'll teach you loads about your kitten
</p>
<a class="mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--accent kitty-hero__text-button" href="#intro">
<i class="material-icons">keyboard_arrow_down</i>
</a>
</div>
<!-- /.hero-text -->
</div>
<!-- /.hero-section -->
<!-- INTRO -->
<div id="intro" class="mdl-grid intro-section">
<div class="about-kitty mdl-cell mdl-cell--12-col">
<p class="mdl-typography--headline">
Welcome to Kaptain Kitty! This is a demo HTML template that accompanies an article for SitePoint. The article illustrates how to use the Material Design Lite library to build a web page. You're free to use this template as you like. All images on this
demo are courtesy of <a href="https://pixabay.com/">Pixabay.com</a>.
</p>
</div>
<!-- /.about-kitty -->
<div class="about-kitty mdl-cell mdl-cell--12-col">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint dolorum consectetur natus sequi, est similique! Temporibus rem consequuntur laudantium, illo excepturi velit quas. Culpa ipsum dolor tempore accusantium sed iusto.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut, dicta aliquid, inventore a ullam excepturi similique sit, nobis incidunt laboriosam amet maxime iusto nam facilis possimus quo optio? Dolor, et?
</p>
</div>
<!-- /.about-kitty -->
<div class="about-kitty mdl-cell mdl-cell--5-col mdl-cell--1-col-tablet mdl-cell--hide-phone">
<div class="circle-container">
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
<div class="circle"></div>
</div>
<!-- /.circle-container -->
</div>
<!-- /.about-kitty -->
<div class="about-kitty mdl-cell mdl-cell--7-col mdl-cell--6-col-tablet mdl-cell--4-col-phone">
<div class="topics-container">
<div class="topic">Feeding</div>
<div class="topic">Choosing the right vet</div>
<div class="topic">Keeping you kittens healthy</div>
<div class="topic">Adopting a kitten</div>
<div class="topic">Vaccinating your kitten</div>
</div>
<!-- /.topics-container -->
</div>
<!-- /.about-kitty -->
<div class="about-kitty mdl-cell mdl-cell--12-col">
<p class="clearfix">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/cat.jpg" class="embedded-img float-left"> Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint dolorum consectetur natus sequi, est similique! Temporibus
rem consequuntur laudantium, illo excepturi velit quas. Culpa ipsum dolor tempore accusantium sed iusto. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut, dicta aliquid, inventore a ullam excepturi similique sit, nobis incidunt
laboriosam amet maxime iusto nam facilis possimus quo optio? Dolor, et?
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ut, dicta aliquid, inventore a ullam excepturi similique sit, nobis incidunt laboriosam amet maxime iusto nam facilis possimus quo optio? Dolor, et?
</p>
</div>
<!-- /.about-kitty -->
</div>
<!--/.mdl-grid -->
<!-- Testimonial -->
<div class="mdl-grid mdl-grid--no-spacing fullwidth-panel">
<div class="mdl-cell mdl-cell--12-col mdl-typography--text-center quote-panel">
<blockquote>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint dolorum consectetur natus sequi, est similique! Temporibus rem consequuntur laudantium, illo excepturi velit quas. Culpa ipsum dolor tempore accusantium sed iusto.
</p>
<footer>
— <cite>Happy Kitten Owner</cite>
</footer>
</blockquote>
</div>
<!-- /.mdl-cell -->
</div>
<!--/.mdl-grid -->
</div>
<!-- /.page-content -->
</div>
<!-- /.tab1 -->
<div class="mdl-layout__tab-panel" id="fixed-tab-2">
<div class="page-content">
<!-- Your content goes here -->
<!-- CARDS -->
<div class="mdl-grid cards-section">
<div class="mdl-cell mdl-cell--6-col mdl-cell--12-col-tablet mdl-card mdl-shadow--2dp home-bringing-card">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Bringing a kitten into your home</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
</div>
<!-- /.mdl-card -->
<div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp play-card">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Playing with your kitten</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
</div>
<!-- /.mdl-card -->
<div class="mdl-cell mdl-cell--2-col mdl-cell--4-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp image-card">
<div class="mdl-card__actions">
<span class="image-card__title">KaptainKitty.jpg</span>
</div>
</div>
<!-- /.mdl-card -->
<div class="mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp litter-card">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Taking care of a litter of kittens</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
</div>
<!--/.mdl-card -->
<div class="mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp diet-card">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Healthy diet for your kitten</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--accent mdl-js-button mdl-js-ripple-effect">
Learn about feeding
</a>
</div>
</div>
<!--/.mdl-card -->
<div class="mdl-cell mdl-cell--3-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp card-small">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Kitten behavior</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--accent mdl-js-button mdl-js-ripple-effect">
More on behavior
</a>
</div>
</div>
<!--/.mdl-card -->
<div class="mdl-cell mdl-cell--3-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp card-small">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Finding a vet</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--accent mdl-js-button mdl-js-ripple-effect">
More on finding a vet
</a>
</div>
</div>
<!--/.mdl-card -->
<div class="mdl-cell mdl-cell--3-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp card-small">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Toys for kittens</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--accent mdl-js-button mdl-js-ripple-effect">
More on toys
</a>
</div>
</div>
<!--/.mdl-card -->
<div class="mdl-cell mdl-cell--3-col mdl-cell--8-col-tablet mdl-cell--4-col-phone mdl-card mdl-shadow--2dp card-small">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">Adopting a kitten</h2>
</div>
<div class="mdl-card__supporting-text">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Dolorem explicabo reiciendis corporis, optio animi autem, quisquam, temporibus sed deleniti officiis dolor eveniet tempore ad nulla deserunt laudantium, obcaecati esse! Officia.
</div>
<div class="mdl-card__actions mdl-card--border">
<a class="mdl-button mdl-button--accent mdl-js-button mdl-js-ripple-effect">
More on adopting
</a>
</div>
</div>
<!--/.mdl-card -->
</div>
<!--/.mdl-grid -->
</div>
<!-- /.page-content -->
</div>
<!-- /tab2 -->
<!-- Contact -->
<div class="mdl-grid mdl-grid--no-spacing">
<div class="mdl-cell mdl-cell--12-col contact-intro mdl-color--indigo-900">
<h2 class="mdl-typography--title mdl-typography--title-color-contrast mdl-typography--font-thin mdl-typography--text-center">Make your kittens happier with my tips</h2>
</div>
<!--/.contact-intro -->
<div class="mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet mdl-cell--4-col-phone contact-panel form-panel mdl-color--indigo-50">
<form action="#">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="text" id="name">
<label class="mdl-textfield__label" for="name">Your name</label>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label">
<input class="mdl-textfield__input" type="email" id="email">
<label class="mdl-textfield__label" for="email">Your email</label>
</div>
<div class="button-container clearfix">
<button class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent subscribe-button">
Join my fans
</button>
</div>
<!--/.button-container -->
</form>
</div>
<!--/.contact-panel -->
<div class="mdl-cell mdl-cell--6-col mdl-cell--8-col-tablet mdl-cell--4-col-phone contact-panel address-panel mdl-typography--text-center mdl-color--indigo-100">
<p class="mdl-typography--title-color-contrast mdl-typography--text-nowrap mdl-typography--font-thin">
<i class="material-icons">email</i> <a href="mailto:info@captain.kitty.com">info@kaptain.kitty.com</a>
</p>
<p class="mdl-typography--title-color-contrast mdl-typography--text-nowrap mdl-typography--font-thin">
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" href="twitter.com">twitter</a>
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" href="plus.google.com">Google+</a>
<a class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" href="facebook.com">Facebook</a>
</p>
</div>
<!-- /.contact-panel -->
</div>
<!-- /.mdl-grid -->
<!-- FOOTER -->
<footer class="mdl-mini-footer mdl-color--indigo-200">
<div class="mdl-mini-footer__left-section">
<div class="mdl-logo">Kaptain Kitty – designed by <a href="http://wpthememakeover.com">Maria Antonietta Perna</a></div>
<ul class="mdl-mini-footer__link-list">
<li><a href="#">Help</a></li>
<li><a href="#">Privacy & Terms</a></li>
</ul>
© Maria Antonietta Perna 2016
</div>
<!-- /.mdl-mini-footer__left-section -->
</footer>
</main>
<!-- /.mdl-layout__content -->
</div>
<!-- /.mdl-layout -->
img {
max-width: 100%;
height: auto;
display: block;
}
ul {
list-style-type: none;
}
/* UTILITIES */
.clearfix:after {
content: "";
display: table;
clear: both;
}
.float-right {
float: right;
}
.float-left {
float: left;
}
/* TABS */
.mdl-layout__tab-bar {
margin: 0 auto;
max-width: 300px;
}
/* DRAWER */
.mdl-layout__drawer-button,
.mdl-layout__drawer-button i {
color: white;
}
@media (max-width: 900px) {
.mdl-layout__drawer-button {
width: 100%;
margin: 0;
background-color: transparent;
}
}
.avatar {
height: 200px;
width: 200px;
margin: 0 auto 2em;
}
.avatar-img {
height: 200px;
width: 200px;
margin: 0 auto;
border-radius: 50%;
}
.drawer-text {
padding: 1em;
text-align: center;
}
/* HERO SECTION */
.hero-section {
height: 100vh;
/* IE11 doesn't like min-height */
width: 100%;
margin: 0;
padding: 0;
background-color: rgba(63, 81, 181, 0.6);
background-image: linear-gradient(rgba(63, 81, 181, 0.3), rgba(63, 81, 181, 0.3)), url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/hero-bg.jpg);
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
position: relative;
display: flex;
flex-direction: column;
margin: auto;
}
.hero-text {
color: white;
margin: auto;
}
@media screen and (max-width: 580px) {
.hero-text p {
white-space: pre-line;
}
}
.kitty-hero__text-button {
position: absolute;
bottom: -28px;
left: 50%;
transform: translateX(-50%);
}
/* ABOUT KITTY INTRO + CARDS */
.intro-section,
.cards-section {
max-width: 960px;
}
/* ABOUT KITTY INTRO */
.intro-section {
padding: 5em 2em 5em;
}
.about-kitty p {
max-width: 640px;
margin: auto;
}
.circle-container {
width: 100%;
min-height: 100px;
padding: 2em 0;
display: flex;
flex-direction: column;
align-items: flex-end;
}
.circle-container .circle {
height: 16px;
width: 16px;
background-color: #c51162;
border-radius: 50%;
margin: 0 3px 9px;
}
.topics-container {
padding: 2em 0;
}
.topics-container .topic {
font-size: 20px;
margin: 0 2px 5px;
}
@media screen and (max-width: 480px) {
.topics-container .topic {
margin-bottom: 0.5em;
}
}
.embedded-img {
max-width: 150px;
max-height: 150px;
margin: 0.5em;
border-radius: 50%;
}
/* CARDS SECTION */
.cards-section {
padding: 5em 0;
}
.mdl-card__title {
min-height: 300px;
color: white;
}
.home-bringing-card .mdl-card__title {
background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.8)), url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/kitten-home.jpg') center / cover;
}
.play-card .mdl-card__title {
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/kitten-on-tree.jpg') center / cover;
}
.image-card {
background: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/image-card.jpg') center / cover;
}
.image-card > .mdl-card__actions {
height: 52px;
padding: 16px;
background: rgba(0, 0, 0, 0.6);
}
.image-card__title {
color: #fff;
font-size: 14px;
font-weight: 500;
}
.litter-card .mdl-card__title {
background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.8)), url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/litter-card.jpg') center / cover;
}
.diet-card .mdl-card__title {
background: linear-gradient(rgba(0, 0, 0, 0.1), rgba(0, 0, 0, 0.8)), url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/diet-card.jpg') center / cover;
}
.card-small {
min-height: auto;
}
.card-small > .mdl-card__title {
color: rgba(0, 0, 0, 0.87);
height: auto;
min-height: auto;
}
.card-small .mdl-card__title-text {
font-size: 16px;
}
.card-small .mdl-card__title-text:before {
content: "";
display: inline-block;
margin-right: 0.5em;
width: 18px;
height: 18px;
background-color: #c51162;
border-radius: 50%;
}
/* FULLWIDTH BACKGROUND SECTION */
.fullwidth-panel {
color: white;
background-color: rgba(156, 39, 176, 0.6);
}
.fullwidth-panel p {
max-width: 640px;
margin: auto;
}
.quote-panel {
background-image: linear-gradient(rgba(63, 81, 181, 0.5), rgba(63, 81, 181, 0.5)), url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/234228/panel-bg.jpg');
background-position: center 5%;
background-repeat: no-repeat;
background-size: cover;
padding: 4em 2em 2em;
display: flex;
align-content: flex-start;
}
@media screen and (min-width: 800px) {
.quote-panel {
background-position: center 0;
padding: 6em 2em;
}
}
@media screen and (min-width: 1200px) {
.quote-panel {
background-position: center 8%;
padding: 10em 2em 8em;
}
}
.contact-intro {
color: rgba(255, 255, 255, 0.87);
}
.contact-panel {
padding: 6em 4em;
display: flex;
flex-direction: column;
margin: auto;
}
.mdl-textfield {
display: block;
width: 100%;
padding: 20px 0;
}
@media screen and (min-width: 800px) {
.subscribe-button {
float: right;
}
}
.address-panel {
background-color: #dbdef1;
color: rgba(255, 255, 255, 0.87);
}
.address-panel .material-icons {
position: relative;
top: 0.2em;
display: inline-block;
height: 30px;
width: 30px;
line-height: 30px;
background-color: #ff4081;
padding: 0.5em;
border-radius: 50%;
}
.mdl-mini-footer,
.mdl-mini-footer .mdl-logo,
.mdl-mini-footer--link-list a,
.mdl-mini-footer__link-list a {
color: rgba(0, 0, 0, 0.54);
}
Also see: Tab Triggers