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.
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,900" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<title>3D-Cube-Transform</title>
</head>
<body>
<div class="wrapper">
<div class="burger"></div>
<ul class="menu">
<li class="menu-item"><a class="menu_item__link" href="#">Our story</a></li>
<li class="menu-item"><a class="menu_item__link" href="#">Menu</a></li>
<li class="menu-item"><a class="menu_item__link" href="#">Catering</a></li>
<li class="menu-item"><a class="menu_item__link" href="#">Events</a></li>
<li class="menu-item"><a class="menu_item__link" href="#">Chef's corner</a></li>
<li class="menu-item"><a class="menu_item__link" href="#">Contact</a></li>
</ul>
<div class="scene">
<div class="cube">
<div class="side top">
<h1 class="side__title">Drinks in the sun</h1>
<p class="side__desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt pariatur nostrum repellat tempora dignissimos delectus magnam iusto, quibusdam facilis aliquam suscipit corporis temporibus qui, labore necessitatibus debitis cum. Nobis blanditiis,
iste delectus.</p>
<button class="side__btn">Show more</button>
</div>
<div class="side bottom">
<h1 class="side__title">The Three Pizza Recipes</h1>
<p class="side__desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Non neque suscipit totam ratione accusamus sunt, fugit voluptatum tempora aut praesentium, illo earum, optio dolorem! Consequuntur quos at tempore minus velit molestias obcaecati.</p>
<button class="side__btn">Show more</button>
</div>
<div class="side front">
<h1 class="side__title">That’s What I Love About Sunday</h1>
<p class="side__desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Debitis illo, obcaecati, voluptatum unde dicta atque voluptas, dolorem sapiente non, voluptates eum at laudantium quis cum architecto itaque labore neque accusamus. Doloribus, quas.</p>
<button class="side__btn">Show more</button>
</div>
<div class="side back">
<h1 class="side__title">Great for Summer or Anytime</h1>
<p class="side__desc">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nisi modi, repudiandae maxime doloribus possimus rerum velit consectetur, ipsam atque ullam, delectus ab illum quisquam sit neque at deleniti iusto dolor nobis corrupti.</p>
<button class="side__btn">Show more</button>
</div>
</div>
</div>
<div class="scene scene_rotator">
<div class="rotator">
<div class="side top">1</div>
<div class="side bottom">2</div>
<div class="side front">3</div>
<div class="side back">4</div>
</div>
</div>
</div>
<script src="js/main.js" type="text/javascript"></script>
</body>
</html>
:root {
--width-cube: 75vw;
--height-cube: 90vh;
--width-rotator: 50px;
--height-rotator: 50px;
--gradient-bg-from: #b3cae5;
--gradient-bg-to: #f7ddbb;
--gradient-btn-one: #ffa067;
--gradient-btn-two: #ff2959;
--gradient-btn-three: #ff2024;
}
* {
margin: 0;
padding: 0;
}
body {
font-family: "Lato", sans-serif;
background: linear-gradient(
45deg,
var(--gradient-bg-from),
var(--gradient-bg-to)
);
}
.wrapper {
width: 100%;
height: 100vh;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
position: relative;
}
.scene {
-webkit-perspective: calc(var(--height-cube)*2);
perspective: calc(var(--height-cube)*2);
width: var(--width-cube);
height: var(--height-cube);
}
.scene_rotator {
position: absolute;
right: 0;
top: 50%;
width: var(--width-rotator);
height: var(--height-rotator);
margin-top: calc((var(--height-rotator)/2*(-1)));
}
.cube {
position: relative;
width: var(--width-cube);
height: var(--height-cube);
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-animation-duration: 10s;
animation-duration: 10s;
-webkit-animation-name: rotate;
animation-name: rotate;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.side {
width: inherit;
height: inherit;
position: absolute;
top: 0;
left: 0;
font-weight: bold;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
color: #fff;
background: #000;
text-align: center;
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
}
.side::before {
content: "";
display: block;
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background: rgba(0, 0, 0, 0.3);
}
.side__title {
text-transform: uppercase;
font-size: 58px;
margin-bottom: 36px;
margin-top: 45px;
text-shadow: 24px 42px 58px -8px rgba(0, 0, 0, 0.4);
-webkit-transform: translateZ(70px);
transform: translateZ(70px);
width: 650px;
}
.side__desc {
font-size: 12px;
width: 600px;
line-height: 24px;
-webkit-transform: translateZ(70px);
transform: translateZ(70px);
text-shadow: 24px 42px 58px -8px rgba(0, 0, 0, 0.4);
}
.side__btn {
margin-top: 40px;
padding: 12px 35px;
border: none;
color: #fff;
background: linear-gradient(
135deg,
var(--gradient-btn-one) 0%,
var(--gradient-btn-two) 49%,
var(--gradient-btn-three) 100%
);
-webkit-transform: translateZ(60px);
transform: translateZ(60px);
filter: progid:DXImageTransform.Microsoft.gradient(
startColorstr="#ffa067",
endColorstr="#ff2024",
GradientType=1
);
-webkit-box-shadow: 24px 42px 58px -8px rgba(0, 0, 0, 0.9);
box-shadow: 24px 42px 58px -8px rgba(0, 0, 0, 0.9);
}
.cube > .top {
background: url("https://images.unsplash.com/photo-1490474418585-ba9bad8fd0ea?dpr=1&auto=compress,format&fit=crop&w=1350&h=&q=80&cs=tinysrgb&crop=");
background-size: cover;
background-repeat: no-repeat;
-webkit-transform: rotateX(90deg) translateZ(calc(var(--height-cube)/2));
transform: rotateX(90deg) translateZ(calc(var(--height-cube)/2));
}
.cube > .bottom {
background: url("https://images.unsplash.com/photo-1496412705862-e0088f16f791?dpr=1&auto=compress,format&fit=crop&w=1350&h=&q=80&cs=tinysrgb&crop=");
background-size: cover;
background-repeat: no-repeat;
-webkit-transform: rotateX(-90deg) translateZ(calc(var(--height-cube)/2));
transform: rotateX(-90deg) translateZ(calc(var(--height-cube)/2));
}
.cube > .back {
background: url("https://images.unsplash.com/photo-1497888329096-51c27beff665?dpr=1&auto=compress,format&fit=crop&w=1351&h=&q=80&cs=tinysrgb&crop=");
background-size: cover;
background-repeat: no-repeat;
-webkit-transform: rotateY(180deg) rotateZ(180deg)
translateZ(calc(var(--height-cube)/2));
transform: rotateY(180deg) rotateZ(180deg)
translateZ(calc(var(--height-cube)/2));
}
.cube > .front {
background: url("https://images.unsplash.com/photo-1464305795204-6f5bbfc7fb81?dpr=1&auto=compress,format&fit=crop&w=2550&h=&q=80&cs=tinysrgb&crop=");
background-size: cover;
background-repeat: no-repeat;
-webkit-transform: translateZ(calc(var(--height-cube)/2));
transform: translateZ(calc(var(--height-cube)/2));
}
.rotator {
position: relative;
width: var(--width-rotator);
height: var(--height-rotator);
-webkit-transform-style: preserve-3d;
transform-style: preserve-3d;
-webkit-animation-duration: 10s;
animation-duration: 10s;
-webkit-animation-name: rotate;
animation-name: rotate;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.rotator > .top {
-webkit-transform: rotateX(90deg) translateZ(calc(var(--height-rotator)/2));
transform: rotateX(90deg) translateZ(calc(var(--height-rotator)/2));
}
.rotator > .bottom {
-webkit-transform: rotateX(-90deg) translateZ(calc(var(--height-rotator)/2));
transform: rotateX(-90deg) translateZ(calc(var(--height-rotator)/2));
}
.rotator > .back {
-webkit-transform: rotateY(180deg) rotateZ(180deg)
translateZ(calc(var(--height-rotator)/2));
transform: rotateY(180deg) rotateZ(180deg)
translateZ(calc(var(--height-rotator)/2));
}
.rotator > .front {
-webkit-transform: translateZ(calc(var(--height-rotator)/2));
transform: translateZ(calc(var(--height-rotator)/2));
}
.burger {
position: absolute;
top: 5%;
left: 3%;
width: 16px;
height: 16px;
cursor: pointer;
background-size: contain;
background-repeat: no-repeat;
z-index: 10000;
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHMAAABkCAMAAACCTv/3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAAZQTFRF////5ubmueBsSwAAAAJ0Uk5T/wDltzBKAAAAPklEQVR42uzYQQ0AAAgDseHfNC4IyVoD912WAACUm3uampqampqamq+aAAD+IVtTU1NTU1NT0z8EAFBsBRgAX+kR+Qam138AAAAASUVORK5CYII=);
}
.menu {
position: absolute;
top: 0;
left: 0;
width: 50%;
height: 100%;
padding: 80px 0;
z-index: 999;
visibility: hidden;
-webkit-transform: translateX(-100vw);
transform: translateX(-100vw);
font-weight: bold;
background: rgba(255, 255, 255, 0.2);
-webkit-backdrop-filter: blur(6px);
backdrop-filter: blur(6px);
-webkit-transition: 0.5s;
transition: 0.5s;
}
.menu_active {
visibility: visible;
list-style-type: none;
-webkit-transform: translateX(0);
transform: translateX(0);
}
.menu_item__link {
display: block;
margin: 10px 0px 10px 85px;
color: #fff;
text-decoration: none;
font-size: 32px;
-webkit-transition: 0.3s;
transition: 0.3s;
}
.menu_item__link:hover {
-webkit-transform: translateX(20px);
transform: translateX(20px);
}
@-webkit-keyframes rotate {
0% {
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
25% {
-webkit-transform: rotateX(90deg);
transform: rotateX(90deg);
}
50% {
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
75% {
-webkit-transform: rotateX(270deg);
transform: rotateX(270deg);
}
100% {
-webkit-transform: rotateX(360deg);
transform: rotateX(360deg);
}
}
@keyframes rotate {
0% {
-webkit-transform: rotateX(0deg);
transform: rotateX(0deg);
}
25% {
-webkit-transform: rotateX(90deg);
transform: rotateX(90deg);
}
50% {
-webkit-transform: rotateX(180deg);
transform: rotateX(180deg);
}
75% {
-webkit-transform: rotateX(270deg);
transform: rotateX(270deg);
}
100% {
-webkit-transform: rotateX(360deg);
transform: rotateX(360deg);
}
}
(function() {
const burger = document.getElementsByClassName("burger")[0];
const menu = document.getElementsByClassName("menu")[0];
const activeClass = "menu_active";
burger.onclick = event => {
if (menu.classList.contains(activeClass)) {
menu.classList.remove(activeClass);
} else {
menu.classList.add(activeClass);
}
};
})();
Also see: Tab Triggers