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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<!-- GRID -->
<div class="wrapper">
<!-- HEADER -->
<p class="head">hover on the pictures</p>
<!-- MAIN -->
<!-- BLACK TO INVERT -->
<div class="div black invert">
<button><div></div></button>
<p>black to <span>white</span></p>
</div>
<!-- BLACK TO COLOR -->
<div class="div black color">
<button><div></div></button>
<p>black to <span>color</span>*</p>
</div>
<!-- WHITE TO INVERT -->
<div class="div white invert">
<button><div></div></button>
<p>white to <span>black</span></p>
</div>
<!-- WHITE TO COLOR -->
<div class="div white color">
<button><div></div></button>
<p>white to <span>color</span>*</p>
</div>
<!-- FOOTER -->
<p class="foot">*Please, consider playing with the <span>$bg-color</span> and the <span>$color</span> in the CSS. Changing to some colors will require more adjustements to work properly.</p>
<p class="foot">See updated version <a href="https://codepen.io/salixdubois/pen/LYNgJbM">here</a> that uses mask instead</p>
</div>
<!-- THE END -->
@import url("https://fonts.googleapis.com/css?family=Lato")
@import "susy"
@import "breakpoint"
//== SETUP ==================================================
$bg: teal
@mixin hover($c)
border: solid 1px $c
background-color: rgba(0,0,0,0) //no bg, doesn't work with black Oo
//===========================================================
//== WHITE TO COLOR ========================================
//===========================================================
$icon-white: red
white-span
color: $icon-white
white
@include hover($icon-white)
&::before, &::after
//-- for white you need to get the opposite color -------
background: invert($icon-white)
//-----------------------------------------------------------
//-- UNCOMMENT TO TRY OTHER COLORS AND ADJUSTMENT -----------
//-- exemple with pink ------------------------------------
//$icon-white-adjust: pink //-- change & see below
//white-adjust-span
// color: $icon-white-adjust
//white-adjust
// @include hover($icon-white-adjust)
// &::after
// background: invert($icon-white-adjust)
// &::before
// background: adjust-color($bg, $lightness: 12.3%, $hue: -3)
// mix-blend-mode: normal
//-----------------------------------------------------------
//-- exemple with goldenrod -------------------------------
//$icon-white-adjust: goldenrod //-- change & see below
//white-adjust-span
// color: $icon-white-adjust
//white-adjust
// @include hover($icon-white-adjust)
// &::after
// background: invert($icon-white-adjust)
// &::before
// background: adjust-color($bg, $hue: -38, $saturation: -30, $lightness: 25.5)
// mix-blend-mode: normal
//-----------------------------------------------------------
//===========================================================
//== BLACK to COLOR ========================================
//===========================================================
$icon-black: cyan
black-span
color: $icon-black
black
@include hover($icon-black)
&::before, &::after
background: $icon-black
//-----------------------------------------------------------
//-- uncomment this section to check the adjustments --------
$icon-black-adjust: goldenrod
//black-adjust-span
// color: $icon-black-adjust
//black-adjust
// @include hover($icon-black-adjust)
// &::before
// background: change-color($bg, $hue: 295, $lightness: 84.5%)
// mix-blend-mode: difference
// &::after
// background: $icon-black-adjust
//-----------------------------------------------------------
//===========================================================
//== IMAGES STYLING =========================================
//===========================================================
//== BLACK ==================================================
.black
color: black
button
@include hover(black)
div
background: url("https://upload.wikimedia.org/wikipedia/commons/b/b9/FP_Mushroom_icon.svg") center no-repeat
background-size: contain
//-- TO INVERT ----------------------------------------------
.black.invert
span
color: white
button
&:hover
@include hover(white)
&::before, &::after
background-color: white
//-- TO COLOR -----------------------------------------------
.black.color
span
@extend black-span
@extend black-adjust-span !optional
button
&:hover
@extend black
@extend black-adjust !optional
//-----------------------------------------------------------
//== WHITE ==================================================
.white
color: white
button
@include hover(white)
div
background: url(https://upload.wikimedia.org/wikipedia/commons/d/db/Sun_white_icon.svg) center no-repeat
background-size: contain
//-- TO INVERT ----------------------------------------------
.white.invert
span
color: black
button
&:hover
@include hover(black)
&::before, &::after
//-- for white you need the opposite color ---------
background-color: white
//-- TO COLOR -----------------------------------------------
.white.color
span
@extend white-span
@extend white-adjust-span !optional
button
&:hover
@extend white
@extend white-adjust !optional
//-----------------------------------------------------------
//===========================================================
//== RESPONSIVE GRID SUZY+BREAKPOINT========================
//===========================================================
$bp0: 0px
$bp1: 450px
$bp2: 600px
$bp3: 800px
$bp4: 1000px
$susy: (gutters: 1/4, gutter-position: split)
//-----------------------------------------------------------
.wrapper
width: 90%
@include breakpoint($bp0)
min-width: (0.9*$bp1)
@include breakpoint($bp1)
max-width: (0.8*$bp2)
@include breakpoint($bp2)
max-width: (0.6*$bp3)
@include breakpoint($bp3)
max-width: (0.9*$bp4)
//-----------------------------------------------------------
.foot
@include span(100%)
@include breakpoint($bp0)
font-size: 10px
@include breakpoint($bp1)
font-size: 11px
@include breakpoint($bp2)
font-size: 12px
@include breakpoint($bp3)
font-size: 14px
@include breakpoint($bp4)
font-size: 16px
//-----------------------------------------------------------
.head
@include span(100%)
@include breakpoint($bp0)
font-size: 24px
margin: 5% 0
@include breakpoint($bp1)
font-size: 26px
margin: 3% 0
@include breakpoint($bp2)
font-size: 30px
margin: 3% 0
@include breakpoint($bp3)
font-size: 36px
margin: 5% 0
//-----------------------------------------------------------
.div
@include span(1 of 2)
@include breakpoint($bp0)
font-size: 13px
@include breakpoint($bp1)
font-size: 14px
@include breakpoint($bp2)
font-size: 15px
@include breakpoint($bp3)
font-size: 16px
@include span(1 of 4)
margin-bottom: gutter(4)
//===========================================================
//== GENERAL STYLING =======================================
//===========================================================
html, body
height: 100%
width: 100%
background-color: $bg
font-family: 'Lato', sans-serif
text-transform: uppercase
text-align: center
.wrapper
height: 100%
margin: 0 auto
position: relative
.head
font-weight: bold
text-shadow: -1px -1px lighten($bg, 16%), -1px 0 lighten($bg, 10%), 0 -1px lighten($bg, 10%), 1px 0 darken($bg, 10%), 1px 1px darken($bg, 16%), 0 1px darken($bg, 10%)
color: lighten($bg, 4%)
letter-spacing: 4px
.div
position: relative
&::before
padding-top: 100%
display: block
content: ""
p
position: absolute
bottom: 0
left: 0
width: 100%
button
position: absolute
top: 0
left: 10%
cursor: pointer
width: 80%
height: 75%
padding: 10% 0
div
height: 100%
position: relative
&::after, &::before
mix-blend-mode: difference
position: absolute
top: 0
left: 0
width: 100%
height: 100%
content: ""
.foot
span
font-weight: bold
//== THE END ================================================
/*
Guess some updates made it
not work as well as it used too,
will have to figure the color
again
*/
Also see: Tab Triggers