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.
<!-- header - start -->
<div id="headerWrap">
<div class="js-modal-bk" @click="modalBkClick" :class="{active:modal_bk}"></div>
<header class="header">
<div class="headerInner">
<div id="js-open-menu" class="header__menu" @click="mainMenuToggle" :class="{active:headerMenu_state}">
<span class="header__menu__line"></span>
<span class="header__menu__line"></span>
<span class="header__menu__line"></span>
</div>
<!-- header__menu -->
<!-- MENU INNER - start --------------------------------------------------------------------------------------------->
<div class="header__menu__inner" :class="{active:headerMenu_state}">
<ul class="header__menuList">
<li><a href="">
<span>
sample
</span>
</a></li>
<li><a href="">
<span>
sample
</span>
</a></li>
</ul><!-- header__menuList -->
</div><!-- header__menu__inner -->
<!-- MENU INNER - end --------------------------------------------------------------------------------------------->
<h1 class="header__logo">logo</h1>
</div>
<!-- headerInner -->
</header>
</div>
<!-- header - end -->
/* ------------------------------------ */
// リセット
/* ------------------------------------ */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video
margin: 0
padding: 0
border: 0
color: #333333
font-size: 100%
vertical-align: baseline
box-sizing: border-box
h1, h2, h3, h4, h5, h6
font-weight: 500
line-height: 1.4
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section
display: block
li
list-style: none
/* ------------------------------------ */
// mixin
/* ------------------------------------ */
@mixin afterContent($top,$right,$bottom,$left,$widh,$height)
position: absolute
top: $top
right: $right
bottom: $bottom
left: $left
width: $widh
height: $height
content: ""
/* ------------------------------------ */
// header
/* ------------------------------------ */
.js-modal-bk
opacity: 0
visibility: hidden
position: fixed
z-index: 12
top: 0
left: 0
width: 100%
height: 100%
background: rgba(0, 0, 0, 0.4)
transition: all .3s
.js-modal-bk.active
opacity: 1
visibility: visible
height: 100vh
overflow: hidden
.header
position: fixed
z-index: 12
top: 0
right: 0
left: 0
width: 100%
margin: 0 auto
background: #fff
border: 2px solid #ccc
.headerInner
display: flex
align-items: center
justify-content: space-between
.header__menu
display: flex
align-items: center
justify-content: center
flex-wrap: wrap
position: relative
width: 44px
height: 46px
padding: 13px 10px
transition: all .4s
.header__menu__line
display: block
width: 15px
height: 2px
margin: 0 auto 0 0
background: #0257BD
transition: all .4s
&:nth-child(3)
width: 10px
.header__menu.active
.header__menu__line
position: relative
width: 17px
&:nth-of-type(1)
top: -2px
transform: translateY(5px) rotate(-45deg)
&:nth-of-type(2)
opacity: 0
&:nth-of-type(3)
top: 0
width: 17px
transform: translateY(-10px) rotate(45deg)
.header__notice
display: flex
align-items: center
justify-content: center
position: absolute
top: 7px
right: -5px
min-width: 20px
min-height: 20px
padding: 2px
box-sizing: border-box
background: rgb(233, 84, 93)
border-radius: 50%
color: #fff
font-size: 10px
span
display: inline-block
margin-left: 2px
color: #fff
.header__logo
display: flex
align-items: center
justify-content: center
position: absolute
top: 0
right: 0
bottom: 0
left: 0
width: 32%
margin: auto
.header__iconWrap
display: flex
.header__icon
display: block
padding: 10px 11px
img
width: 100%
.header__menu__inner
position: fixed
top: 50px
left: 0
width: 82%
height: calc(100vh - 46px)
background: #fff
font-size: 14px
transform: translateX(-100%)
transition: all .3s
.header__menu__inner.active
transform: translateX(0)
.header__menuList
margin-bottom: 20px
>li
position: relative
border-bottom: 1px solid rgb(240, 243, 246)
&:after
@include afterContent(0, 18px, 0, auto, 0, 0)
margin: auto
border-top: 6px solid transparent
border-bottom: 6px solid transparent
border-left: 6px solid rgb(2, 87, 189)
a
display: block
padding: 15px 45px 15px 15px
line-height: 1.5
span
position: relative
.header__notice
top: 0
right: -30px
bottom: 0
margin: auto
new Vue({
el: '#headerWrap',
data: {
headerMenu_state: false,
modal_bk: false,
},
methods: {
mainMenuToggle: function () {
if (this.headerMenu_state == true) {
this.headerMenu_state = false;
this.modal_bk = false;
return;
}
this.headerMenu_state = true;
this.modal_bk = true;
},
modalBkClick: function () {
this.headerMenu_state = false;
this.modal_bk = false;
},
}
});
Also see: Tab Triggers