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.
// My blog: https://albertwalicki.com
// Inspiration https://www.freepik.com/free-vector/flat-design-house-illustration-set_9857282.htm
div.wrapper
div.roof
div.roofShadow1
div.roofShadow2
div.roofPatch1
div.roofPatch2
div.roofPatch3
div.roofPatch4
div.roofPatch5
div.roofPatch6
div.roofInner
div.building
div.topPart
div.window1
div.bottomPart
div.path
div.leftPart
div.windowsMiddle
div.window1
div.window2
div.rightPart
div.door
div.windowsBottom
div.window1
div.window2
div.grass
div.tree
div.treeBody
div.treeTop
div.treeMiddle
div.treeBottom
div.treeTrunk
div.road
* {
box-sizing: border-box;
}
$size: 1vmin;
$size00675: calc(0.0675 * #{$size});
$size0125: calc(0.125 * #{$size});
$size025: calc(0.25 * #{$size});
$size05: calc(0.5 * #{$size});
$size075: calc(0.75 * #{$size});
$size15: calc(1.5 * #{$size});
$size2: calc(2 * #{$size});
$size3: calc(3 * #{$size});
$size4: calc(4 * #{$size});
$size5: calc(5 * #{$size});
$road: #575757;
$sky: #cbe0f4;
$grass: #859e53;
$grassDark: #6a8344;
$frame: #fff;
$building1: #edebe7;
$building2: #d9d7d6;
$building3: #b6b6b6;
$foundation: #7d7874;
$door: #4f4132;
$doorKnob: #d7d8d5;
$doorLight: #5d4f40;
$brown: #aa5e51;
$darkBrown: #8f554b;
$window: #51a8c2;
$windowDark: #1e3e48;
$windowLight: rgba(255, 255, 255, 0.15);
$roofShadow: #8f5549;
.wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: flex-end;
height: 100vh;
width: 100%;
background: $sky;
}
.road {
height: $size4;
width: 100%;
background: $road;
}
.grass {
height: $size2;
width: 100%;
background: $grass;
}
.building {
width: calc(#{$size} * 29);
height: calc(#{$size} * 32.5);
border-left: $size15 solid $frame;
border-right: $size15 solid $frame;
background: $frame;
position: relative;
}
.roof {
width: 0;
height: 0;
border-style: solid;
border-width: 0 calc(14.5 * #{$size}) calc(12 * #{$size})
calc(14.5 * #{$size});
border-color: transparent transparent $frame transparent;
position: relative;
}
.roofInner {
width: 0;
height: 0;
border-style: solid;
border-width: 0 calc(13 * #{$size}) calc(11 * #{$size}) calc(13 * #{$size});
border-color: transparent transparent transparent transparent;
position: absolute;
top: $size2;
left: 0;
transform: translateX(-50%);
}
.roofPatch1 {
width: $size2;
height: $size;
background: $frame;
position: absolute;
left: calc(-13.5 * #{$size});
top: calc(12 * #{$size});
}
.roofPatch2 {
width: $size2;
height: $size;
background: $frame;
position: absolute;
right: calc(-13.5 * #{$size});
top: calc(12 * #{$size});
}
.roofPatch3 {
width: $size;
height: $size3;
background: $frame;
position: absolute;
left: calc(-14.05 * #{$size});
top: calc(13 * #{$size});
z-index: 6;
}
.roofPatch4 {
width: $size;
height: $size3;
background: $frame;
position: absolute;
right: calc(-14.05 * #{$size});
top: calc(13 * #{$size});
z-index: 6;
}
.roofPatch5 {
width: $size;
height: $size3;
background: $frame;
position: absolute;
z-index: 7;
top: $size;
left: calc(0.5 * #{$size});
transform: rotate(-51deg);
}
.roofPatch6 {
width: $size;
height: $size3;
background: $frame;
position: absolute;
z-index: 7;
top: $size;
left: calc(-1.7 * #{$size});
transform: rotate(51deg);
}
.roofShadow1 {
background: $roofShadow;
height: calc(1.5 * #{$size});
width: calc(18.5 * #{$size});
transform: rotate(140deg);
position: absolute;
top: calc(7.9 * #{$size});
left: calc(-15.7 * #{$size});
z-index: 5;
}
.roofShadow2 {
background: $roofShadow;
height: calc(1.5 * #{$size});
width: calc(18.5 * #{$size});
transform: rotate(-140deg);
position: absolute;
top: calc(7.9 * #{$size});
right: calc(-15.7 * #{$size});
z-index: 5;
}
.topPart {
width: 100%;
height: calc(21.5 * #{$size});
background-image: linear-gradient(
0deg,
#af6356 4.55%,
#aa5e51 4.55%,
#aa5e51 50%,
#af6356 50%,
#af6356 54.55%,
#aa5e51 54.55%,
#aa5e51 100%
);
background-size: $size5 $size5;
position: absolute;
top: -8vmin;
clip-path: polygon(50% 0, 50% 0, 100% 50%, 100% 100%, 0 100%, 0% 50%);
.window1 {
position: absolute;
top: calc(9 * #{$size});
left: calc(4.5 * #{$size});
width: calc(4.4 * #{$size});
height: calc(9.5 * #{$size});
border: calc(0.4 * #{$size}) solid $frame;
background: linear-gradient(
180deg,
$window 50%,
$window 50%,
$windowDark 50%
);
&:before {
content: "";
width: 100%;
height: 100%;
background: linear-gradient(
-64deg,
transparent 20%,
$windowLight 20%,
$windowLight 26%,
transparent 26%,
transparent 60%,
$windowLight 60%,
$windowLight 66%,
transparent 66%
);
position: absolute;
}
}
}
.bottomPart {
width: 100%;
height: calc(19 * #{$size});
background: pink;
position: relative;
top: 13.5vmin;
display: flex;
}
.leftPart {
width: 50%;
height: 100%;
background: $building1;
border-bottom: $size2 solid $foundation;
}
.rightPart {
width: 50%;
height: 100%;
background: linear-gradient(
to bottom,
$building3 0vmin,
$building3 calc(2.5 * #{$size}),
$building2 calc(2.5 * #{$size})
);
}
.door {
width: calc(5.5 * #{$size});
height: calc(12 * #{$size});
background: $door;
position: absolute;
bottom: 0;
right: calc(5.7 * #{$size});
&:before {
content: "";
position: absolute;
top: $size;
bottom: $size;
left: $size;
right: $size;
border: $size00675 solid $doorLight;
}
&:after {
content: "";
position: absolute;
top: calc(4.5 * #{$size});
right: calc(0.8 * #{$size});
width: calc(0.4 * #{$size});
height: calc(3.5 * #{$size});
background: $doorKnob;
}
}
.windowsBottom {
width: calc(4.8 * #{$size});
height: calc(12 * #{$size});
background: $frame;
position: absolute;
bottom: 0;
right: calc(1 * #{$size});
.window1 {
height: calc(5.4 * #{$size});
width: calc(4 * #{$size});
background: $window;
position: relative;
top: calc(0.4 * #{$size});
left: calc(0.4 * #{$size});
&:before {
content: "";
width: 100%;
height: 100%;
background: linear-gradient(
-64deg,
$window 10%,
$windowLight 10%,
$windowLight 16%,
$window 16%,
$window 70%,
$windowLight 70%,
$windowLight 76%,
$window 76%
);
position: absolute;
}
}
.window2 {
height: calc(5.6 * #{$size});
width: calc(4 * #{$size});
background: $windowDark;
position: relative;
top: calc(1 * #{$size});
left: calc(0.4 * #{$size});
&:before {
content: "";
width: 100%;
height: 100%;
background: linear-gradient(
-64deg,
$windowDark 50%,
$windowLight 50%,
$windowLight 56%,
$windowDark 56%
);
position: absolute;
}
}
}
.windowsMiddle {
left: 0;
top: 0;
width: calc(10 * #{$size});
height: calc(4.5 * #{$size});
background: $frame;
.window1 {
position: relative;
top: calc(0.4 * #{$size});
left: calc(0.4 * #{$size});
width: calc(3.3 * #{$size});
height: calc(3.7 * #{$size});
background: linear-gradient(
180deg,
$window 50%,
$window 50%,
$windowDark 50%
);
&:before {
content: "";
width: 100%;
height: 100%;
background: linear-gradient(
-64deg,
transparent 50%,
$windowLight 50%,
$windowLight 58%,
transparent 58%
);
position: absolute;
}
}
.window2 {
position: absolute;
top: calc(0.4 * #{$size});
left: calc(4.2 * #{$size});
width: calc(5.3 * #{$size});
height: calc(3.7 * #{$size});
background: linear-gradient(
180deg,
$window 50%,
$window 50%,
$windowDark 50%
);
&:before {
content: "";
width: 100%;
height: 100%;
background: linear-gradient(
-64deg,
transparent 30%,
$windowLight 30%,
$windowLight 36%,
transparent 36%,
transparent 80%,
$windowLight 80%,
$windowLight 86%,
transparent 86%
);
position: absolute;
}
}
}
.path {
width: calc(5.5 * #{$size});
height: calc(2 * #{$size});
position: absolute;
right: calc(5.7 * #{$size});
bottom: calc(-2 * #{$size});
background: $road;
z-index: 6;
}
.tree {
--width: 20vmin;
--margin: 0 12vmin;
--trunk: #523b36;
--green1: #1a4b27;
--green2: #26713b;
--green3: #32994e;
height: calc(var(--width) * 1.666);
width: var(--width);
position: absolute;
bottom:calc(#{$size} * 6);
left: calc(50% + 12vmin);
margin: var(--margin);
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
}
.treeBody {
display: flex;
flex-direction: column;
justify-content: flex-end;
align-items: center;
}
.treeTrunk {
height: calc(var(--width)/3);
width: calc(var(--width)/7.5);
background-color: var(--trunk);
}
.treeTop {
position: absolute;
width: calc(var(--width)/1.2);
height: calc(var(--width)/1.2);
bottom: calc(var(--width)/4);
border-radius: 50%;
left: calc(var(--width)/1.2/3);
background: var(--green1);
z-index: 5;
}
.treeMiddle {
position: absolute;
width: calc(var(--width)/1.2);
height: calc(var(--width)/1.2);
bottom: calc(var(--width)/4);
border-radius: 50%;
right: calc(var(--width)/1.2/3);
background: var(--green2);
z-index: 4;
}
.treeBottom {
position: absolute;
width: calc(var(--width)/1.2);
height: calc(var(--width)/1.2);
bottom: calc(var(--width)/1.5);
border-radius: 50%;
background: var(--green3);
z-index: 3;
}
Also see: Tab Triggers