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.
.device
nav
span.is-active
a.home(href="#")
i.fas.fa-home
a.search(href="#")
i.fas.fa-search
a.about(href="#")
i.fas.fa-bell
span.badge 7
a.profile.active(href="#")
i.fas.fa-user
.pages
.comp.comp-home
header
h1 home
section
p content
footer
small footer
.comp.comp-search
header
h1 search
section
p content
footer
small footer
.comp.comp-about
header
h1 about
section
p content
footer
small footer
.comp.comp-profile.is-active
header
h1 Joshua Ward
.avatar
.details
.followers
h3 1325
span followers
.following
h3 1985
span following
.Favorites
h3 1111
span favorites
section
h5 posts
.feed
.feed-item
.user
.user-avatar
.post
span.user-name Gary Busey
span.user-handle @garybusey
span.post-date
span.date 13
span.month January
span.year 2019
span.time 15:43
p.content Busey ipsum dolor sit amet. It's OK to get Rib-grease on your face, because you're allowing people to see that you're proud of these ribs. Did you feel that?
.feed-item
.user
.user-avatar
.post
span.user-name Gary Busey
span.user-handle @garybusey
span.post-date
span.date 13
span.month January
span.year 2019
span.time 15:43
p.content Busey ipsum dolor sit amet. It's OK to get Rib-grease on your face, because you're allowing people to see that you're proud of these ribs. Did you feel that?
.feed-item
.user
.user-avatar
.post
span.user-name Gary Busey
span.user-handle @garybusey
span.post-date
span.date 13
span.month January
span.year 2019
span.time 15:43
p.content Busey ipsum dolor sit amet. It's OK to get Rib-grease on your face, because you're allowing people to see that you're proud of these ribs. Did you feel that?
.feed-item
.user
.user-avatar
.post
span.user-name Gary Busey
span.user-handle @garybusey
span.post-date
span.date 13
span.month January
span.year 2019
span.time 15:43
p.content Busey ipsum dolor sit amet. It's OK to get Rib-grease on your face, because you're allowing people to see that you're proud of these ribs. Did you feel that?
.feed-item
.user
.user-avatar
.post
span.user-name Gary Busey
span.user-handle @garybusey
span.post-date
span.date 13
span.month January
span.year 2019
span.time 15:43
p.content Busey ipsum dolor sit amet. It's OK to get Rib-grease on your face, because you're allowing people to see that you're proud of these ribs. Did you feel that?
.feed-item
.user
.user-avatar
.post
span.user-name Gary Busey
span.user-handle @garybusey
span.post-date
span.date 13
span.month January
span.year 2019
span.time 15:43
p.content Busey ipsum dolor sit amet. It's OK to get Rib-grease on your face, because you're allowing people to see that you're proud of these ribs. Did you feel that?
.loading-more
i.fas.fa-sync-alt
footer
a(href="#") posts
a(href="#") posts with replies
a(href="#") favorites
a(href="#") media
$base-duration: 250ms;
// Colors
$primary: #4DB6AC;
$accent: #46627f;
$white: whitesmoke;
$light-gray: #999;
$active: #3498db;
$red: #e74c3c;
// Breakpoints
$sm: 20rem;
$med: 48rem;
$lg: 64rem;
// fonts
$sans-serif: 'Roboto', sans-serif;
$slab-serif: 'Roboto Slab', serif;
*, *:before, *:after {
box-sizing: border-box;
outline: none;
}
html {
font-family: $sans-serif;
font-size: 16px;
font-smooth: auto;
font-weight: lighter;
line-height: 1.5;
color: #444;
}
body {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
}
h1, h2, h3, h4, h5 {
font-family: $slab-serif;
}
p {
margin-top: 0 !important;
}
.device {
position: relative;
display: block;
width: 375px;
height: 667px;
background-color: lighten($primary,10%);
border-radius: 10px;
box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
overflow: hidden;
}
.badge {
position: absolute;
display: flex;
align-items: center;
justify-content: center;
top: 10px;
right: 10px;
width: 15px;
height: 15px;
padding-top: 1px;
background-color: $red;
//border: 1px solid white;
border-radius: 50%;
box-shadow: 1px 1px 0 darken($accent,5%);
font-size: 10px;
font-weight: bold;
line-height: 1;
z-index: 99;
.active & {
color: $white;
}
}
.pages {
position: relative;
display: block;
width: 100%;
height: 100%;
.comp {
position: relative;
display: none;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
width: 100%;
height: 100%;
margin: 0;
padding: 0 0 60px;
background-color: lighten($accent,30%);
transform: translateX(0%);
transition: 0.25s;
animation: slideIn 0.25s ease;
&.is-active {
display: flex;
}
&-home {
}
&-search {
}
&-about {
}
&-profile {
.details {
position: relative;
display: flex;
align-items: center;
justify-content: space-around;
width: 100%;
padding: 20px 100px 20px 0;
background-color: $white;
> div {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
text-align: center;
> span {
font-size: 12px;
}
}
h3 {
margin: 0;
padding: 0;
color: $primary;
font-size: 16px;
font-weight: 700;
}
}
}
header {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
flex: 0 0 10%;
width: 100%;
padding: 10px 15px;
background-color: $primary;
background-image: url('https://images.pexels.com/photos/459225/pexels-photo-459225.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=750&w=1260');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
&:before {
position: absolute;
content: '';
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba($primary,0.8);
z-index: 0;
}
h1 {
margin: 0;
padding: 0;
color: $white;
font-size: 28px;
text-shadow: 1px 1px $accent;
animation: headingSlide 0.5s linear;
z-index: 1;
}
.avatar {
position: relative;
width: 100px;
height: 100px;
margin-top: 60px;
background-image: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/50325/profile/profile-80.jpg?100000');
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
border-radius: 50%;
border: 5px solid white;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
text-align: center;
transform: translateY(0%);
animation: avatarSlide 0.5s ease;
z-index: 99;
span {
position: absolute;
bottom: -30px;
left: 50%;
width: 100%;
color: $light-gray;
font-size: 11px;
transform: translateX(-50%);
i {
margin-left: 2px;
}
}
}
}
section {
position: relative;
display: flex;
flex-direction: column;
flex: 0 1 auto;
width: 100%;
padding: 10px 15px 0;
background-color: white;
overflow-y: scroll;
h5 {
margin: 0;
//background: red;
color: $light-gray;
text-transform: uppercase;
}
.feed {
position: relative;
flex: 1 0 auto;
width: 100%;
//height: 100%;
.feed-item {
position: relative;
display: flex;
align-items: flex-start;
width: 100%;
padding: 15px 10px;
border-bottom: 1px solid lighten($light-gray,30%);
.user {
position: relative;
display: flex;
align-items: center;
flex: 0 1 50px;
padding-right: 10px;
&-avatar {
position: relative;
display: flex;
align-items: center;
justify-content: center;
width: 40px;
height: 40px;
background-color: lightgray;
border: 3px solid $white;
border-radius: 50%;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
&:before {
position: absolute;
content: '\f007';
font-family: "Font Awesome 5 Free";
font-size: 12px;
}
}
}
.post {
position: relative;
font-size: 12px;
.user-name {
font-weight: bold;
}
.user-handle {
font-weight: bold;
color: $primary;
}
.post-date {
color: $light-gray;
}
p.content {
margin: 0;
}
}
}
}
}
footer {
position: relative;
display: flex;
align-items: center;
justify-content: space-around;
flex: 0 0 auto;
width: 100%;
padding: 3px 20px;
background-color: $white;
> a {
color: $primary;
font-size: 12px;
text-decoration: none;
}
}
}
}
@keyframes slideIn {
0% { transform: translateX(-100%); }
100% { transform: translateX(0%); }
}
@keyframes headingSlide {
0% { transform: translateX(-100%); }
50% { transform: translateX(30%); }
75% { transform: translateX(-30%); }
100% { transform: translateX(0); }
}
@keyframes avatarSlide {
0% { transform: translateY(-300%); }
100% { transform: translateY(0%); }
}
nav {
position: absolute;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
width: 375px;
height: 60px;
background-color: lighten($accent,10%);
//border-radius: 0 0 8px 8px;
box-shadow: 0 0 3px rgba(0,0,0,0.12), 0 0 2px rgba(0,0,0,0.24);
overflow: hidden;
z-index: 9999;
// &:before {
// position: absolute;
// content: '';
// top: -5px;
// left: 0;
// width: 100%;
// height: 5px;
// background-color: rgba($accent,0.4);
// }
span.is-active {
position: absolute;
top: 0;
left: 75%;
width: 25%;
height: 100%;
background-color: $white;
box-shadow: 0 0 10px 0 rgba(black,0.4);
transition: left 0.25s ease-in-out;
z-index: 0;
&:before {
position: absolute;
content: '';
top: 0;
left: 0;
width: 100%;
height: 5px;
background-color: $primary;
z-index: 1;
}
}
a {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 25%;
height: 100%;
padding: 0;
color: $white;
text-decoration: none;
&.active {
color: $primary;
}
> i {
font-size: 18px;
}
> div {
font-size: 12px;
}
}
}
.loading-more {
position: relative;
display: flex;
align-items: center;
justify-content: center;
padding: 30px 0;
color: $primary;
animation: spinner 1s linear infinite;
}
@keyframes spinner {
100% { transform: rotate(360deg);}
}
$('nav').find('a').click(function() {
$('nav').find('a.active').removeClass('active');
$(this).addClass('active');
if($('a.active').is('.search')) {
$('span.is-active').css('left','25%');
} else if($('a.active').is('.about')) {
$('span.is-active').css('left','50%');
} else if($('a.active').is('.profile')) {
$('span.is-active').css('left','75%');
} else {
$('span.is-active').css('left','0%');
}
if($('.search').is('.active')) {
$('.pages').find('.is-active').removeClass('is-active');
$('.comp-search').addClass('is-active');
} else if($('.about').is('.active')) {
$('.pages').find('.is-active').removeClass('is-active');
$('.comp-about').addClass('is-active');
} else if($('.profile').is('.active')) {
$('.pages').find('.is-active').removeClass('is-active');
$('.comp-profile').addClass('is-active');
} else {
$('.pages').find('.is-active').removeClass('is-active');
$('.comp-home').addClass('is-active');
};
});
Also see: Tab Triggers