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="wrapper d-flex h-100">
<aside class="sidebar h-100">
<div class="sidebar-section sidebar-header">
<div class="sidebar-logo text-center">
<a href="#" class="text-light">Modern Sidebar</a>
</div>
</div>
<div class="sidebar-section sidebar-profile pt-4 pb-4">
<div class="profile-picture">
<div class="picture-wrapper rounded-circle ml-auto mr-auto">
<img src="https://www.magic931.com.au/assets/docs/Jon_Snow.PNG?1543200080" class="img-fluid" alt="">
</div>
<span class="profile-alert"></span>
<div class="profile-details text-center mt-2">
<div class="name">Jhon Snow</div>
<small class="role">King in the north</small>
</div>
</div>
</div>
<div class="sidebar-section sidebar-menu p-0">
<ul class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
<li class="nav-item">
<a class="nav-link rounded-0 active" id="menu-tab" data-toggle="tab" href="#menu" role="tab" aria-controls="menu" aria-selected="true">
<i class="fas fa-bars"></i>
</a>
</li>
<li class="nav-item">
<a class="nav-link rounded-0" id="notifications-tab" data-toggle="tab" href="#notifications" role="tab" aria-controls="notifications" aria-selected="false">
<i class="far fa-bell"></i>
<span class="nav-alert bg-danger"></span>
</a>
</li>
<li class="nav-item">
<a class="nav-link rounded-0" id="messages-tab" data-toggle="tab" href="#messages" role="tab" aria-controls="messages" aria-selected="false">
<i class="far fa-comment"></i>
<span class="nav-alert bg-success"></span>
</a>
</li>
<li class="nav-item">
<a class="nav-link rounded-0" id="settings-tab" data-toggle="tab" href="#settings" role="tab" aria-controls="settings" aria-selected="false">
<i class="fas fa-cogs"></i>
</a>
</li>
</ul>
<div class="tab-content" id="myTabContent">
<div class="tab-pane fade show active pt-3 pb-2" id="menu" role="tabpanel" aria-labelledby="menu-tab">
<div class="tab-header text-uppercase p-2">
Menu
</div>
<ul>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fas fa-tachometer-alt"></i>
<span class="menu-text flex-fill">Dashboard</span>
<span class="badge badge-pill badge-warning rounded-0">NEW</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="far fa-gem"></i>
<span class="menu-text flex-fill">Componenets</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fa fa-chart-line"></i>
<span class="menu-text flex-fill">Charts</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fa fa-shopping-cart"></i>
<span class="menu-text flex-fill">E-commerce</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fa fa-globe"></i>
<span class="menu-text flex-fill">Maps</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fa fa-calendar"></i>
<span class="menu-text flex-fill">Calendar</span>
<span class="badge badge-pill badge-primary rounded-0">BETA</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fa fa-book"></i>
<span class="menu-text">Documentation</span>
</a>
</li>
</ul>
</div>
<div class="tab-pane fade pt-3 pb-2" id="notifications" role="tabpanel" aria-labelledby="notifications-tab">
<div class="tab-header text-uppercase p-2">
Notifications
</div>
<ul>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="icon">
<i class="fas fa-check text-center text-success border border-success"></i>
</div>
<div class="notification-content flex-fill overflow-hidden">
<div class="notification-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="notification-time">6 minutes ago</div>
</div>
</a>
</li>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="icon">
<i class="fas fa-exclamation-triangle text-center text-warning border border-warning"></i>
</div>
<div class="notification-content flex-fill overflow-hidden">
<div class="notification-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="notification-time">Yesterday</div>
</div>
</a>
</li>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="icon">
<i class="fas fa-exclamation text-center text-info border border-info"></i>
</div>
<div class="notification-content flex-fill overflow-hidden">
<div class="notification-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="notification-time">2 day ago</div>
</div>
</a>
</li>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="icon">
<i class="fas fa-times text-center text-danger border border-danger"></i>
</div>
<div class="notification-content flex-fill overflow-hidden">
<div class="notification-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
<div class="notification-time">A week ago</div>
</div>
</a>
</li>
</ul>
<div class="tab-footer text-center">
<a href="#" class="btn rounded-0 btn-block">View all notifications</a>
</div>
</div>
<div class="tab-pane fade pt-3 pb-2" id="messages" role="tabpanel" aria-labelledby="messages-tab">
<div class="tab-header text-uppercase p-2">
Messages
</div>
<ul>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="pic">
<img src="https://www.magic931.com.au/assets/docs/Jon_Snow.PNG?1543200080" alt="">
</div>
<div class="message-content flex-fill overflow-hidden">
<div class="message-title text-nowrap text-truncate">
Jhon Snow
</div>
<div class="message-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
</div>
</a>
</li>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="pic">
<img src="https://www.magic931.com.au/assets/docs/Jon_Snow.PNG?1543200080" alt="">
</div>
<div class="message-content flex-fill overflow-hidden">
<div class="message-title text-nowrap text-truncate">
Jhon Snow
</div>
<div class="message-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
</div>
</a>
</li>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="pic">
<img src="https://www.magic931.com.au/assets/docs/Jon_Snow.PNG?1543200080" alt="">
</div>
<div class="message-content flex-fill overflow-hidden">
<div class="message-title text-nowrap text-truncate">
Jhon Snow
</div>
<div class="message-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
</div>
</a>
</li>
<li>
<a class="p-2 d-flex align-items-center text-decoration-none" href="#">
<div class="pic">
<img src="https://www.magic931.com.au/assets/docs/Jon_Snow.PNG?1543200080" alt="">
</div>
<div class="message-content flex-fill overflow-hidden">
<div class="message-title text-nowrap text-truncate">
Jhon Snow
</div>
<div class="message-detail text-nowrap text-truncate">Lorem ipsum dolor sit amet consectetur adipisicing elit.</div>
</div>
</a>
</li>
</ul>
<div class="tab-footer text-center">
<a href="#" class="btn rounded-0 btn-block">View all messages</a>
</div>
</div>
<div class="tab-pane fade pt-3 pb-2" id="settings" role="tabpanel" aria-labelledby="settings-tab">
<div class="tab-header text-uppercase p-2">
Settings
</div>
<ul>
<li>
<a href="#" class="d-flex align-items-center">
<i class="far fa-user"></i>
<span class="flex-fill">Profile</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="far fa-question-circle"></i>
<span class="flex-fill">Help</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fas fa-cog"></i>
<span class="flex-fill">Settings</span>
</a>
</li>
<li>
<a href="#" class="d-flex align-items-center">
<i class="fas fa-power-off"></i>
<span class="flex-fill">Logout</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</aside>
<main class="page-content p-4">
<h5>Modern Sidebar template </h5>
<p>A modern sidebar template built with bootstrap 4 </p>
<a id="toggle-sidebar" href="#" class="btn btn-outline-dark rounded-0">Toggle Sidebar</a>
</main>
</div>
body {
height: 100vh;
}
$sidebar-width: 280px;
$sidebar-bg-color: #292e38;
.wrapper {
aside.sidebar {
width: $sidebar-width;
min-width: $sidebar-width;
background: $sidebar-bg-color;
overflow-x:hidden;
position: relative;
&.toggled{
width: 0;
min-width: 0;
}
.sidebar-section {
padding: 1.2rem 0;
border-bottom: 1px solid lighten($sidebar-bg-color, 8%);
}
.sidebar-profile {
.picture-wrapper {
width: 60px;
height: 60px;
overflow: hidden;
}
.profile-details{
.name{
color: lighten($sidebar-bg-color, 40%);
}
.role{
color: lighten($sidebar-bg-color, 25%);
}
}
}
.sidebar-menu {
ul#nav-tab {
border-bottom: 1px solid lighten($sidebar-bg-color, 8%);
padding-bottom: 1px;
li {
border-right: 1px solid lighten($sidebar-bg-color, 8%);
&:last-child {
border-right: none;
}
a {
color: lighten($sidebar-bg-color, 20%);
border: none;
position: relative;
&.active {
background: lighten($sidebar-bg-color, 4%);
color: lighten($sidebar-bg-color, 40%);
.nav-alert{
border-color: lighten($sidebar-bg-color, 4%);
}
}
&:hover {
color: lighten($sidebar-bg-color, 40%);
}
.nav-alert {
display: inline-block;
width: 13px;
height: 13px;
border-radius: 50%;
position: absolute;
top: 5px;
border: 3px solid $sidebar-bg-color;
transform:translateX(2px);
&.bg-danger {
box-shadow: 0px 0px 4px #ff6161;
}
&.bg-success {
box-shadow: 0px 0px 4px #61ff66;
}
}
}
}
}
.tab-header {
color: lighten($sidebar-bg-color, 40%);
font-size: 0.9rem;
font-weight: bold;
}
.tab-footer a {
color: lighten($sidebar-bg-color, 40%);
&:hover {
color: lighten($sidebar-bg-color, 50%);
}
}
#menu {
ul {
list-style-type: none;
padding: 0;
li a {
padding: 0.5rem 0.6rem;
text-decoration: none;
color: lighten($sidebar-bg-color, 25%);
i {
width: 35px;
height: 35px;
text-align: center;
line-height: 35px;
color: lighten($sidebar-bg-color, 25%);
font-size: 0.9rem;
border:1px solid lighten($sidebar-bg-color, 8%);
margin-right: 0.5rem;
}
.menu-text {
font-size: 0.9rem;
}
.badge {
font-size: 0.6rem;
}
&:hover {
color: lighten($sidebar-bg-color, 30%);
background:lighten($sidebar-bg-color, 3%);
i {
color: lighten($sidebar-bg-color, 40%);
}
}
}
}
}
#messages {
ul {
list-style-type: none;
padding: 0;
a {
.pic {
width: 45px;
min-width: 45px;
height: 45px;
overflow: hidden;
margin-right: 1rem;
img {
width: 100%;
height: 100%;
object-fit: cover;
object-position: center;
}
}
.message-content {
text-decoration: none;
.message-title {
color: lighten($sidebar-bg-color, 50%);
}
.message-detail {
color: lighten($sidebar-bg-color, 20%);
font-size: 0.9rem;
}
}
&:hover {
background: lighten($sidebar-bg-color, 3%);
}
}
}
}
#notifications {
ul {
list-style-type: none;
padding: 0;
a {
.icon i {
width: 40px;
min-width: 40px;
height: 40px;
line-height: 40px;
overflow: hidden;
margin-right: 1rem;
}
.notification-content {
text-decoration: none;
.notification-detail {
color: lighten($sidebar-bg-color, 40%);
font-size: 0.9rem;
}
.notification-time {
color: lighten($sidebar-bg-color, 20%);
font-size: 0.7rem;
}
}
&:hover {
background: lighten($sidebar-bg-color, 3%);
}
}
}
}
#settings {
ul {
list-style-type: none;
padding: 0;
li a {
padding: 0.5rem 0.6rem;
text-decoration: none;
color: lighten($sidebar-bg-color, 25%);
i {
color: lighten($sidebar-bg-color, 30%);
margin-right: 0.8rem;
}
&:hover {
color: lighten($sidebar-bg-color, 40%);
}
}
}
}
}
}
}
document.getElementById("toggle-sidebar").addEventListener("click", () => {
let sidebar = document.querySelector(".sidebar");
if (sidebar.classList.contains("toggled"))
document.querySelector(".sidebar").classList.remove("toggled");
else document.querySelector(".sidebar").classList.add("toggled");
});
Also see: Tab Triggers