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.
.daybox
label
input#switch_night(type="checkbox")
.top
svg.temsvg
text(x=0 y=100) 26°
circle(cx=0 cy=100 r=3)
text(x=70 y=80) 27°
circle(cx=70 cy=80 r=3)
text(x=140 y=60) 28°
circle(cx=140 cy=60 r=3)
text(x=210 y=70) 27.8°
circle(cx=210 cy=70 r=3)
text(x=280 y=100) 26.3°
circle(cx=280 cy=100 r=3)
text(x=350 y=110) 26°
circle(cx=350 cy=110 r=3)
text(x=420 y=80) 25.8°
circle(cx=420 cy=80 r=3)
text(x=490 y=80) 30°
circle(cx=490 cy=90 r=3)
text(x=560 y=560) 27°
circle(cx=560 cy=560 r=3)
polyline(points="0,100 70,80 140,60 210,70 280,100 350,110 420,80 490,90 560,90 630,100")
.text_area
.temperature 26°C
.infos
.address 新竹市香山區茄苳里
.time 星期三 上午4:00
.moon
.cloud
.rain
.rain.rain2
.rain.rain3
.bottom
.dayweather
h3 MON
svg(viewbox="-50 -50 100 100")
circle.sun(cx=0 cy=0 r=22)
.dayweather
h3 TUE
svg(viewbox="-50 -50 100 100")
circle.sun(cx=0 cy=0 r=22)
.dayweather
h3 WED
svg(viewbox="-50 -50 100 100")
circle.sun(cx=0 cy=0 r=22)
circle.cloud(cx=-30 cy=30 r=20)
circle.cloud(cx=-15 cy=30 r=20)
circle.cloud(cx=0 cy=30 r=20)
circle.cloud(cx=-25 cy=10 r=15)
circle.cloud(cx=-7 cy=15 r=15)
.dayweather
h3 THU
svg(viewbox="-50 -50 100 100")
circle.sun(cx=0 cy=0 r=22)
circle.cloud(cx=-30 cy=30 r=20)
circle.cloud(cx=-15 cy=30 r=20)
circle.cloud(cx=0 cy=30 r=20)
circle.cloud(cx=-25 cy=10 r=15)
circle.cloud(cx=-7 cy=15 r=15)
.dayweather
h3 FRI
svg(viewbox="-50 -50 100 100")
circle.sun(cx=0 cy=0 r=22)
.dayweather
h3 SAT
svg(viewbox="-63 -40 100 100")
circle.cloud(cx=-30 cy=30 r=20)
circle.cloud(cx=-15 cy=30 r=20)
circle.cloud(cx=0 cy=30 r=20)
circle.cloud(cx=-25 cy=10 r=15)
circle.cloud(cx=-7 cy=15 r=15)
.dayweather
h3 SUN
svg(viewbox="-63 -40 100 100")
line.rain(x1=-25 y1=15 x2=-25 y2=35)
line.rain(x1=-14 y1=5 x2=-14 y2=25)
line.rain(x1=-5 y1=20 x2=-5 y2=45)
circle.cloud(cx=-30 cy=30 r=20)
circle.cloud(cx=-15 cy=30 r=20)
circle.cloud(cx=0 cy=30 r=20)
circle.cloud(cx=-25 cy=10 r=15)
circle.cloud(cx=-7 cy=15 r=15)
$color_white: #f3f3f3
$color_yellow: #FFD633
$color_black: #333
$color_blue_start: #19283D
$color_blue_end: #1D678F
$color_rain: #4DACFF
$color_white_cloud: #f2f9fe
$color_grey_cloud: #ccc
*
// border: solid 1px #777
position: relative
font-family: 'Hind Vadodara','微軟正黑體'
// box-sizing: border-box
@mixin size($w,$h)
width: $w
height: $h
body,html
+size(100%,100%)
margin: 0
padding: 0
background-color: #222
display: flex
justify-content: center
align-items: center
.daybox
width: 50%
max-width: 400px
position: absolute
box-shadow: 0px 0px 20px rgba(0,0,0,0.2), 0px 25px 60px -10px rgba(0,0,0,0.3)
border-radius: 5px
overflow: hidden
transition-duration: 2s
cursor: pointer
&:hover
& .bottom
height: 100px
& .dayweather
opacity: 1
top: 0px
.top
background: linear-gradient(20deg,$color_blue_start 0%,$color_blue_end 95%)
background-size: 100% 300%
height: 330px
animation: daylight 5s linear both
transition-duration: 0.5s
& .text_area
color: $color_white
position: absolute
bottom: 25px
left: 27px
& .temperature
display: block
font-size: 75px
margin-bottom: 0px
font-weight: 100
transition-duration: 0.5s
& .infos
margin-top: -10px
display: block
letter-spacing: 1px
font-size: 13px
opacity: 0.7
transition-duration: 0.5s
@keyframes daylight
0%
background-position: 100% 30%
100%
background-position: 100% 100%
.bottom
height: 10px
background-color: $color_white
transition-duration: 1s
border-radius: 0px 0px 5px 5px
box-shadow: 0px 0px 30px rgba(0,0,0,0.3)
display: flex
justify-content: center
.dayweather
padding: 2px
margin-top: 10px
width: calc(100% / 7 - 5px)
box-sizing: border-box
text-align: center
opacity: 0
top: 20px
transition: 0.5s
svg
width: 100%
max-width: 30px
& .sun
fill: $color_yellow
stroke-width: 30px
stroke: rgba($color_yellow,0.5)
stroke-dasharray: 5px
& .rain
stroke: $color_rain
stroke-width: 5px
& .cloud
fill: $color_grey_cloud
h3
text-align: center
font-size: 8px
font-weight: 400
color: $color_black
letter-spacing: 1px
.dayweather:nth-child(1)
transition-delay: 0.2s
.dayweather:nth-child(2)
transition-delay: 0.3s
.dayweather:nth-child(3)
transition-delay: 0.4s
.dayweather:nth-child(4)
transition-delay: 0.5s
.dayweather:nth-child(5)
transition-delay: 0.6s
.dayweather:nth-child(6)
transition-delay: 0.7s
.dayweather:nth-child(7)
transition-delay: 0.8s
.moon
+size(50px,50px)
position: absolute
left: 50px
top: 100px
transform: translateX(-12px) translateY(-12px)
border-radius: 100%
box-shadow: 12px 12px 0 0 $color_yellow
animation: moon 50s both
transition-duration: 0.5s
@keyframes moon
0%
transform: translateX(-15px) translateY(15px)
box-shadow: 15px -15px 0 0 $color_yellow
100%
transform: translateX(30px) translateY(-30px)
box-shadow: -30px 30px 0 0 $color_yellow
.cloud
+size(100px,36px)
background-color: $color_white_cloud
border-radius: 20px
position: absolute
left: 200px
bottom: 50px
z-index: 50
animation: floating 3s infinite
box-shadow: 0px 10px 15px rgba(0,0,0,0.2)
transition-duration: 0.5s
&::before,&::after
content: ""
display: block
position: absolute
width: 50px
height: 50px
top: -28px
left: 16px
background-color: $color_white_cloud
border-radius: 25px
z-index: 1
&::after
top: -20px
left: 35px
@keyframes floating
0%
transform: translateY(0px)
50%
transform: translateY(-5px)
100%
transform: translateY(0px)
.rain
+size(2px,10px)
background-color: $color_white
animation: rain 1s infinite linear
left: 45px
bottom: 15px
transition-duration: 0.5s
.rain2
animation-delay: -0.4s
left: 70px
bottom: 20px
.rain3
animation-delay: -0.7s
left: 30px
bottom: 20px
@keyframes rain
0%
transform: translateY(0px)
opacity: 1
70%
opacity: 0.4
100%
transform: translateY(60px)
opacity: 0
.temsvg
width: 100%
transition-duration: 0.5s
& circle
fill: white
opacity: 0.05
transition: 0.5s 0s
& polyline
fill: none
stroke: white
stroke-width: 1px
opacity: 0.05
transition: 0.5s 0.2s
& text
fill: $color_white
opacity: 0
transition: 0.5s 0.5s
transform: translateX(-8px) translateY(25px)
font-size: 10px
label
cursor: pointer
#switch_night
display: none
#switch_night:checked+.top
background-color: $color_white
.temsvg
text,circle
opacity: 0.9
polyline
opacity: 0.7
text
transform: translateX(-8px) translateY(20px)
.cloud
opacity: 0.1
.moon
opacity: 0.1
.infos,.temperature
var test=1;
Also see: Tab Triggers