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(ng-app='MyApp'
ng-controller='AppCtrl')
div#menubar
div.logo
a(href="#")
img(src="https://i.imgur.com/RRtNnOs.png")
ul.middle
div.r1 Project Name <i class="glyphicon glyphicon-pencil"></i>
ul.r2
li.dropdown
button.dropdown-btn(href='#'
data-toggle='dropdown') File
ul.dropdown-menu
li
a(href='#') Action 1
li
a(href='#') Action 2
li
a(href='#') Action 3
li.dropdown
button.dropdown-btn(href='#'
data-toggle='dropdown') Edit
ul.dropdown-menu
li
a(href='#') Action 1
li
a(href='#') Action 2
li
a(href='#') Action 3
li.dropdown
button.dropdown-btn(href='#'
data-toggle='dropdown') Help
ul.dropdown-menu
li
a(href='#') Action 1
li
a(href='#') Action 2
li
a(href='#') Action 3
div.menu-btns
button#comment-btn <i class="material-icons">assignment</i> <span>Comment</span>
button#share-btn <i class="material-icons">supervisor_account</i> <span>Share</span>
button#chat-btn(ng-click='openChatDialog()') <i class="material-icons">chat</i> <span>Chat</span>
button#user-btn
div#user-drop.shadow-1
ul
li Smile
li You
li Goodlookin
li Get Shwify
li Cellar Door Is Beautiful
hr
li Your Profile
ul.links
li Link1
li Link2
li Link3
div#chat-cntnr
div.chat-box(ng-repeat='chat in chat.openChats')
div.chat-header
span.chat-title {{chat}}
button.chat-h-btn.chat-close(ng-click='closeChat()')
i.glyphicon.glyphicon-remove
textarea#chat-input
$codepen-btn-grey: #343436
$codepen-hover-grey: #4d4d50
$codepen-icon-grey: #aeaeae
$codepen-dropdown-grey: #e7e7e7
html, body
padding: 0
margin: 0
height: 100%
width: 100%
ul
padding: 0
margin: 0
#menubar
font-family: sans-serif
background-color: black
display: flex
position: relative
white-space: nowrap
.logo
display: flex
align-items: center
padding: 10px
background-color: lightGrey
img
height: 40px
.middle
padding: 10px
padding-top: 8px
padding-bottom: 0px
color: white
width: 100%
position: relative
font-family: inherit
margin-left: 8px
margin-right: 20px
.r1
font-size: 20px
i
position: relative
top: -1px
font-size: 12px
font-weight: 700
margin-left: 2px
cursor: pointer
&:hover
color: lightGrey
.r2
margin-top: 2px
margin-left: -6px
font-size: 15px
padding-bottom: 6px
li
display: inline-block
.dropdown-btn
position: relative
outline: 0
background-color: transparent
border: none
cursor: pointer
padding: 2px 6px
z-index: 100
margin: 0 1px
margin-top: 1px
&:hover
background-color: grey
.open
.dropdown-btn
background-color: black
margin: 0 !important
border: white 1px solid
border-bottom: none
.dropdown-menu
background-color: black
border: white 1px solid
border-radius: 0
margin-top: -1px
z-index: 10
li
display: block
a
color: white
&:hover
background-color: dodgerBlue
.menu-btns
display: flex
margin: 12px
margin-right: 0px
color: white
right: 0
button
outline: 0
position: relative
background-color: transparent
border-radius: 2px
border: $codepen-btn-grey 3px solid
margin: 0 5px
padding: 2px 12px
font-size: 15px
white-space: nowrap
&:hover
background-color: $codepen-hover-grey
i
position: relative
top: 5px
color: $codepen-icon-grey
span
position: relative
top: -3px
#user-btn
margin: 10px
margin-bottom: 8px
outline: 0
width: 70px
background: url('https://www.fillmurray.com/70/92')
border: none
border-radius: 2px
#chat-btn
background-color: $codepen-btn-grey !important
&:hover
background-color: $codepen-hover-grey !important
.shadow-1
box-shadow: 0 2px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)
transition: all 0.2s ease-in-out
// USER DROP
#user-drop
display: none
position: absolute
right: 0
top: 100%
background-color: white
z-index: 10
ul
list-style-type: none
padding: 6px 0
padding-bottom: 2px
font-size: 15px
font-weight: 500
li
cursor: pointer
padding: 4px 16px
padding-right: 38px
&:hover
background-color: $codepen-dropdown-grey
hr
margin: 8px 0
border-top: black 1px solid
.links
padding-top: 0
li
display: inline-block
padding-right: 2px
font-size: 11px
color: darkGrey
&:hover
background-color: white
color: black
#user-drop.open
display: initial
// user drop
// CHAT DIALOG
md-dialog
position: absolute
right: 25px
top: 80px
svg
position: absolute
left: 16px
top: 11px
// chat
// CHAT
#chat-cntnr
display: none
position: fixed
bottom: 0
right: 0
.chat-box
height: 150px
width: 150px
background-color: lightGrey
border: 1px solid #bfbfbf
margin: 0 4px
position: relative
.chat-box:last-child
margin-right: 0
// CHAT HEADER
.chat-h-btn
padding: 2px 8px
border-radius: 4px
font-size: 10px
background-color: #343436
color: white
border: black 1px solid
position: absolute
top: 4px
&:hover
background-color: #4d4d50
.chat-close
right: 5px
.chat-header
position: relative
padding: 3px
border-bottom: #bfbfbf 1px solid
background-color: #1a1b1c
color: #ccc
font-weight: 900
font-size: 16px
// chat header
// chat input
#chat-input
position: absolute
bottom: 1px
right: 1px
width: 99%
resize: none
//CHAT
angular.module('MyApp', ['ngMaterial', 'ngMessages', 'material.svgAssetsCache'])
.controller('AppCtrl', function($scope, $mdDialog) {
//CHAT
$scope.chat = {};
$scope.chat.openChats = [];
$scope.collaborators = ['Dan', 'Miles', 'Ryan', 'kevin'];
var chatCntnr = document.getElementById('chat-cntnr');
// open a chat box
var isChatOpen = function(user) {
if ($scope.chat.openChats.indexOf(user) < 0) return false;
else return true;
};
$scope.openChat = function(user) {
if (!isChatOpen(user)) {
if (chatCntnr.style.display !== 'flex') {
chatCntnr.style.display = 'flex';
}
$scope.chat.openChats.push(user);
}
$mdDialog.hide();
};
// close a chat box
$scope.closeChat = function(user) {
$scope.chat.openChats.splice($scope.chat.openChats.indexOf(user), 1);
};
// CHAT DIALOG
$scope.openChatDialog = function() {
$mdDialog.show({
scope: $scope,
preserveScope: true,
template: '<md-button ng-click="openChat(\'everybody\')">Everybody</md-button><md-button ng-repeat="user in collaborators" ng-click="openChat(user)"><svg class="status-light" height="17" width="17"><circle cx="8" cy="8" r="8" fill="lightGreen" /></svg>{{user}}</md-button>',
hasBackdrop: false,
clickOutsideToClose: true,
openFrom: '#chat-btn',
closeTo: '#chat-btn'
})
};
});
// chat dialog
// chat
/**
* MENUBAR
*/
var dropdownBtns = document.querySelectorAll('.middle .dropdown-btn');
var dropdowns = document.querySelectorAll('.middle .dropdown');
var userBtn = document.getElementById('user-btn');
var userDrop = document.getElementById('user-drop');
document.addEventListener('click', (e) => {
if (userDrop.classList.contains('open')) {
userDrop.classList.toggle('open');
}
});
userBtn.addEventListener('click', (e) => {
userDrop.classList.toggle('open');
e.stopPropagation();
})
for (var i = 0; i < dropdownBtns.length; i++) {
(function() {
var dropdownBtn = dropdownBtns[i];
var k = i;
dropdownBtn.addEventListener('mouseover', () => {
var x = isDropOpen();
if (x > -1 && x !== k) {
dropdowns[x].classList.toggle('open');
dropdowns[k].classList.toggle('open');
}
})
})();
}
var isDropOpen = () => {
for (var i = 0; i < dropdowns.length; i++) {
var dropdownClasses = dropdowns[i].classList;
if (dropdownClasses.contains('open')) return i;
}
return -1;
}
/**
* menubar
*/
Also see: Tab Triggers