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.
.daybox
label
input#switch_night(type="checkbox")
.top
.moon
.cloud
.rain
.rain.rain2
.rain.rain3
svg.temsvg
circle(cx=0 cy=100 r=3)
text(x=0 y=100) 28°C
circle(cx=70 cy=80 r=3)
text(x=70 y=80) 29°C
circle(cx=140 cy=50 r=3)
text(x=140 y=50) 31°C
circle(cx=210 cy=70 r=3)
text(x=210 y=70) 30°C
circle(cx=280 cy=100 r=3)
text(x=280 y=100) 28°C
circle(cx=350 cy=110 r=3)
text(x=350 y=110) 26°C
polyline(points="0,100 70,80 140,50 210,70 280,100 350,110 420,80 560,560")
.text_area
.temperature 28°C
.infos
.address 屏東縣高樹鄉青山村
.time 星期五 22:00
.bottom
.dayweather
h3 MON
svg(viewbox=" -50 -50 100 100")
circle.sun(cx=0 cy=0 r=20)
.dayweather
h3 THU
svg(viewbox=" -50 -50 100 100")
circle.sun(cx=0 cy=0 r=20)
.dayweather
h3 WED
svg(viewbox=" -50 -50 100 100")
circle.sun(cx=0 cy=0 r=20)
circle.cloud(cx=0 cy=30 r=20)
circle.cloud(cx=-15 cy=30 r=20)
circle.cloud(cx=-30 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=20)
circle.cloud(cx=0 cy=30 r=20)
circle.cloud(cx=-15 cy=30 r=20)
circle.cloud(cx=-30 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=20)
.dayweather
h3 SAT
svg(viewbox=" -50 -50 100 100")
circle.sun(cx=0 cy=0 r=20)
.dayweather
h3 SUN
svg(viewbox=" -63 -20 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=0 cy=30 r=20)
circle.cloud(cx=-15 cy=30 r=20)
circle.cloud(cx=-30 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 black
position: relative
font-family: 'Hind Vadodara', sans-serif,"微軟正黑體"
@mixin size($w,$h)
width: $w
height: $h
html,body
width: 100%
height: 100%
margin: 0
padding: 0
display: flex
justify-content: center
align-items: center
background-color: $color_black
box-shadow: 0px 0px 20px rgba(black,0.3)
label
cursor: pointer
.daybox
width: 50%
max-width: 400px
background-color: $color_white
border-radius: 5px
cursor: pointer
&:hover
.bottom
height: 100px
.dayweather
opacity: 1
top: 0px
.temsvg
width: 100%
polyline
stroke: $color_white
stroke-width: 1px
fill: none
opacity: 0.2
text
fill: $color_white
transform: translateX(-5px) translateY(20px)
font-size: 12px
opacity: 0
circle
fill: $color_white
opacity: 0.2
.rain
+size(2px,10px)
position: absolute
left: 45px
bottom: 15px
animation: raindrop 1s infinite linear
background-color: $color_white
.rain2
left: 70px
bottom: 20px
animation-delay: -0.4s
.rain3
left: 30px
bottom: 20px
animation-delay: -0.7s
@keyframes raindrop
0%
transform: translateY(0px)
100%
transform: translateY(50px)
opacity: 0
.top
height: 330px
background: linear-gradient(20deg,$color_blue_start,$color_blue_end)
background-size: 100% 300%
animation: daylight 20S both
border-radius: 5px 5px 0px 0px
@keyframes daylight
0%
background-position: 100% 30%
100%
background-position: 100% 100%
.moon
+size(50px,50px)
border-radius: 100%
box-shadow: 15px -15px
position: absolute
left: 50px
top: 100px
animation: moonmove 20s infinite
@keyframes moonmove
0%
box-shadow: 15px -15 $color_yellow
transform: translateX(-15px) translateY(15px)
100%
box-shadow: -30px 30px $color_yellow
transform: translateX(30px) translateY(-30px)
.cloud
+size(100px,36px)
position: absolute
left: 200px
bottom: 50px
border-radius: 20px
animation: clouddrift 4s infinite
background-color: $color_white
box-shadow: 0px 0px 20px rgba(black,5)
&:before,&:after
content: ""
// border: solid 1px
display: block
+size(50px,50px)
border-radius: 100px
position: absolute
background-color: $color_white
&:before
left: 16px
top: -28px
&:after
left: 35px
top: -20px
@keyframes clouddrift
0%
transform: translateY(0px)
50%
transform: translateY(-20px)
100%
transform: translateY(0px)
.bottom
height: 10px
display: flex
justify-content: center
box-shadow: 0px 0px 20px rgba(black,0.5)
border-radius: 0px 0px 5px 5px
overflow: hidden
transition-duration: 1s
background-color: #FFF5EE
.dayweather
width: calc(100% / 7 - 5px)
display: inline-block
text-align: center
opacity: 0
top: 20px
transition: 0.5s
h3
font-size: 8px
letter-spacing:1px
svg
width: 100%
max-width: 40px
height: 30px
.sun
fill: $color_yellow
stroke: rgba($color_yellow,0.5)
stroke-width: 30px
stroke-dasharray: 5px
.rain
stroke: $color_rain
.cloud
fill: $color_grey_cloud
.dayweather:nth-child(1)
transition-delay: 0.2s
.dayweather:nth-child(2)
transition-delay: 0.4s
.dayweather:nth-child(3)
transition-delay: 0.6s
.dayweather:nth-child(4)
transition-delay: 0.8s
.dayweather:nth-child(5)
transition-delay: 1s
.dayweather:nth-child(6)
transition-delay: 1.2s
.dayweather:nth-child(7)
transition-delay: 1.4s
.text_area
display: inline-block
position: absolute
bottom: 25px
left: 25px
color: $color_white
& .temperature
font-size: 75px
line-height: 70px
& .infos
font-size: 13px
opacity: 0.5
.moon,.cloud
transition: 0.5s
.temsvg
circle,polyline,text
transition: 0.5s
polyline
transition: 0.5s 0.5s
text
transition: 0.5s 1s
#switch_night
display: none
#switch_night:checked+.top
.moon,.cloud
opacity: 0.3
.temsvg
circle,polyline,text
opacity: 1
// sass顏色們:
// $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
Also see: Tab Triggers