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.
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<!-- <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">-->
</head>
<body id="body">
<div class="nav-container" id="nav-container">
<div class="inner">
<nav class="nav" id="nav">
<div class="nav-wheel" id="draggable">
<div id="rotate">
MARKETING DESIGN DEVELOPMENT WEB PRINT ANIMATION CREATIVES MARKETING DESIGN DEVELOPMENT WEB PRINT ANIMATION CREATIVES</div>
<div id="drag"></div>
</div>
</nav>
</div>
</div>
<div class="logo" id="logo">
<div class="inner">AGENCY</div>
<!-- <span> !</span>-->
</div>
<div class="menu-container" id="menu">
<div class="menu">menu</div>
<div class="close">close</div>
</div>
<div class="wrapper" id="wrapper">
<div id="circ">
<p>TING • DESIGN • DEVELOPMENT • WEB • PRINT • ANIMATION • CREATIVES • MARKE</p>
</div>
<div id="circ2">
<p>
fencing • Algorithm • Clickbait • Chatbot • Generation Z • Live-Streaming • Organic Reach • Voice Search
• SEO • AI • Smart Content • Micro-Moments • Brand Identity • Big Data • Gamification • Web
Personalization • Visual Storytelling • Geofencing • Algorithm • Clickbait • Chatbot • Generation Z •
Live-Streaming • Organic Reach • Voice Search
• SEO • AI • Smart Content • Micro-Moments • Brand Identity • Big Data • Gamification • Web
Personalization • Visual Storytelling • Geo
</p>
</div>
<div id="circ3">
<p>
Moments • Micro-Moments • Brand Identity • Big Data • Gamification • Algorithm • Clickbait • Chatbot •
Generation Z • Live-Streaming • Organic Reach • Voice Search
• SEO • AI • Smart Content • Micro-
</p>
</div>
<div class="footer-text">SITE DESIGN CONCEPT</div>
</div>
<div id="main">
<h1 id="title">Creative Studio</h1>
<div id="button">INVERT STYLE</div>
</div>
<!-- script-->
<script type="text/javascript" src="https://cdn.rawgit.com/peterhry/CircleType/master/dist/circletype.min.js">
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/lettering.js/0.7.0/jquery.lettering.min.js"></script>-->
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dat-gui/0.7.5/dat.gui.min.js"></script>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
// colours
$color-white: #fff;
$color-black: #000;
$color-light-grey: #eee;
$color-primary: #ac6b4d;
$color-primary-light: lighten(rgba($color-primary, .7), 55%);
$color-background: #24282B;
$color-text: lighten(#bebbbc, 5%);
$color-border: $color-primary-light;
$color-border-active: rgba($color-black, .8);
// margin
$margin: 24px;
$margin-v: 7%;
$margin-h: 3.5%;
// button anglesf
$angle: 4px;
$angle-o: 2px;
// animation
@keyframes spin {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0deg);
}
}
// mixins
@mixin center {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
margin: auto;
}
@mixin center-x {
position: absolute;
left: 0;
right: 0;
margin: auto;
}
@mixin center-y {
position: absolute;
top: 0;
bottom: 0;
margin: auto;
}
// fonts
@import url('https://fonts.googleapis.com/css?family=Chonburi|Cousine&display=swap');
@font-face {
src: url('https://res.cloudinary.com/dr6lvwubh/raw/upload/v1529908256/CompressaPRO-GX.woff2');
font-family: 'Compressa VF';
font-style: normal;
}
// styles
html {
height: 100%;
width: 100%;
background: darken(#2b2825, 15%);
z-index: 0;
// background: $color-text;
}
.inner {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
body {
@include center;
padding: 0;
overflow: hidden;
background: $color-background;
display: flex;
justify-content: center;
height: 72.5%;
width: 75%;
overflow: hidden;
align-items: center;
overflow: hidden;
z-index: 1;
// invert styles
&.active {
background: $color-white;
h1 {
&.stroke {
span {
-webkit-text-stroke-color: $color-black;
}
}
}
#logo {
// color: $color-primary;
&:after {
background: $color-black;
}
span {
color: $color-black;
}
}
.menu-container {
&:after,
&:before {
background: $color-black;
}
div {
color: black;
}
}
#button {
top: calc(100% + 2px);
right: calc(0% + 3.5px);
box-shadow: -1.5px 1.5px 0 $color-border-active;
// box-shadow: -3px 3px ;
letter-spacing: 1px;
transition: all .15s linear 0s;
z-index: 15;
div {
width: 100%;
height: 100%;
z-index: 1;
}
&:hover {
top: calc(100% + 2px);
right: calc(0% + 3.5px);
box-shadow: -1.5px 1.5px 0 $color-border-active;
&:before {
top: .5px;
left: -1px;
width: $angle-o;
height: $angle-o;
}
&:after {
bottom: -1px;
right: 1px;
width: $angle-o;
height: $angle-o;
}
}
&:before {
transition: all .15s linear 0s;
content: '';
position: absolute;
top: .5px;
left: -1px;
width: $angle-o;
height: $angle-o;
background-color: $color-border-active;
transform: rotate(45deg);
z-index: -1;
}
&:after {
transition: all .15s linear 0s;
content: '';
position: absolute;
bottom: -1px;
right: 1px;
width: $angle-o;
height: $angle-o;
background-color: $color-border-active;
transform: rotate(45deg);
z-index: -1;
}
}
#circ,
#circ2,
#circ3 {
color: $color-black;
}
.footer-text {
color: $color-black;
}
}
}
.nav-container {
position: absolute;
width: 100%;
height: 100%;
.inner {
nav {
position: absolute;
top: 0;
left: 0;
transform: translateY(101%);
background: $color-primary;
width: 100%;
height: 100%;
z-index: 2;
transition: transform .5s cubic-bezier(0.215, 0.61, 0.355, 1);
.nav-wheel {
@include center-x;
bottom: 5%;
width: 100%;
height: 50%;
color: $color-white;
font-size: 6rem;
#rotate {
transition: transform .4s;
}
ul {
list-style: none;
li {
display: inline;
}
}
}
#drag {
@include center-x;
bottom: 0;
width: 100%;
height: 50%;
}
}
&:after,
&:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
// background: $color-primary-light;
background: $color-background;
transform: translateY(101%);
z-index: 3;
}
&:after {
// background: $color-background;
background: $color-primary-light;
z-index: 1;
transition: transform .5s cubic-bezier(0.215, 0.61, 0.355, 1);
}
&:before {
// background: $color-background;
background: $color-primary-light;
z-index: 2;
transition: transform .5s cubic-bezier(0.215, 0.61, 0.355, 1);
}
}
&.active {
.inner {
nav {
transform: translateY(0);
transition: transform 1s cubic-bezier(0.215, 0.61, 0.355, 1) 1s;
}
&:after {
transform: translateY(0);
transition: transform 1s cubic-bezier(0.215, 0.61, 0.355, 1) .5s;
}
&:before {
transform: translateY(0);
transition: transform 1s cubic-bezier(0.215, 0.61, 0.355, 1) 0s;
}
}
}
}
#wrapper {
position: relative;
width: 100%;
height: 100%;
overflow: hidden;
z-index: 0;
}
#main {
position: absolute;
top: 33%;
z-index: 1;
h1 {
// @include center-x;
// top: -15%;
width: 100%;
font-family: 'Compressa VF';
text-rendering: optimizeSpeed;
color: $color-primary;
/* width: 100%; */
user-select: none;
line-height: 0.8em;
margin: 0 auto;
text-transform: uppercase;
font-weight: 200;
text-align: center;
// display: flex;
// justify-content: space-between;
vertical-align: middle;
user-drag: none;
user-select: none;
span {
transform: translateY(-10px);
// transition: all .2s cubic-bezier(0.39, 0.575, 0.565, 1);
}
&.stroke {
span {
position: relative;
// color: #211D26;
color: $color-background;
line-height: inherit;
&:after {
content: attr(data-char);
-webkit-text-stroke-width: 2px;
// -webkit-text-stroke-color: #FE6730;
-webkit-text-stroke-color: $color-primary;
position: absolute;
left: 0;
line-height: inherit;
color: transparent;
z-index: -1;
}
}
}
}
}
#logo {
position: absolute;
top: $margin-v;
left: $margin-h;
width: 3.6vw;
height: 1.6vw;
color: $color-primary;
font-family: 'Compressa VF';
font-size: 2.7vmin;
letter-spacing: -1.5px;
// font-weight: bold;
cursor: pointer;
z-index: 2;
&:after,
&:before {
content: '';
@include center-x;
// left: -30%;
bottom: -6%;
background: $color-text;
width: 100%;
height: 3%;
z-index: 1;
}
&:before {
background: $color-primary;
z-index: 2;
transform: translateY(101%);
transition: transform .5s cubic-bezier(0.215, 0.61, 0.355, 1);
}
&:hover {
&:before {
transform: translateY(0%);
}
}
span {
color: $color-text;
}
&.active {
color: $color-white;
transition: color .5s cubic-bezier(0.215, 0.61, 0.355, 1) 1s;
}
}
#circ,
#circ2,
#circ3 {
font-size: 1vmin;
color: $color-text;
font-family: 'Cousine', monospace;
position: absolute;
top: 25%;
left: 29%;
// margin: auto;
user-drag: none;
user-select: none;
text-transform: uppercase;
animation: spin 20s linear 0s infinite reverse;
z-index: 0;
}
#circ2 {
font-size: 1vmin;
top: 50%;
left: 0%;
animation: spin 95s linear 0s infinite reverse;
}
#circ3 {
font-size: .7vmin;
top: -15%;
left: 96%;
animation: spin 55s linear 0s infinite reverse;
}
.menu-container {
position: absolute;
top: $margin-v;
right: $margin-h;
width: 50px;
height: 25px;
z-index: 2;
cursor: pointer;
&:after,
&:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 1px;
background: rgba($color-white, .8);
transition: .4s;
}
&:before {
top: 8px;
}
div {
position: absolute;
top: 1px;
left: 10.5px;
background: rgba($color-white, 0);
font-family: 'Cousine', monospace;
font-size: 7px;
letter-spacing: 3px;
color: $color-white;
opacity: 0;
text-transform: uppercase;
transition: .3s;
&:nth-child(2) {
left: 8px;
}
}
&:hover {
div,
&:after,
&:before {
transition: .3s;
}
div {
opacity: 1;
&:nth-child(2) {
opacity: 0;
}
}
&:after,
&:before {
transition: .3s;
}
&:after {
top: -8px;
}
&:before {
top: 16px;
}
}
// menu click styles
&.active {
div,
&:after,
&:before {
transition: .4s;
}
&:after {
top: -8px;
}
&:before {
top: 16px;
}
div {
&:nth-child(1) {
opacity: 0;
}
&:nth-child(2) {
opacity: 1;
}
}
&:hover {
div {
&:nth-child(1) {
opacity: 0;
}
}
}
}
}
#button {
@include center-x;
top: 100%;
width: 6.5vw;
// height: 30px;
background: $color-primary;
padding: 15px 25px;
text-align: center;
line-height: 1vmin;
font-size: 1.5vmin;
font-family: 'Compressa VF';
cursor: pointer;
box-shadow: -3px 3px $color-border;
letter-spacing: 1px;
transition: all .15s linear 0s;
// z-index: 6;
div {
width: 100%;
height: 100%;
z-index: 1;
}
&:hover {
top: calc(100% + 2px);
right: calc(0% + 3.5px);
box-shadow: -1.5px 1.5px 0 $color-border;
&:before {
top: .5px;
left: -1px;
width: $angle-o;
height: $angle-o;
}
&:after {
bottom: -1px;
right: 1px;
width: $angle-o;
height: $angle-o;
}
}
&:before {
transition: all .15s linear 0s;
content: '';
position: absolute;
top: 1px;
left: -2px;
width: $angle;
height: $angle;
background-color: $color-border;
transform: rotate(45deg);
z-index: -1;
}
&:after {
transition: all .15s linear 0s;
content: '';
position: absolute;
bottom: -2px;
right: 1px;
width: $angle;
height: $angle;
background-color: $color-border;
transform: rotate(45deg);
z-index: -1;
}
&:active {
top: calc(100% + 3px);
right: calc(0% + 6px);
box-shadow: none;
&:after {
bottom: 1px;
right: 1px;
}
&:before {
top: 1px;
left: 1px;
}
}
}
.footer-text {
position: absolute;
bottom: $margin-v / 2;
right: $margin-h;
font-family: 'Cousine', monospace;
font-size: 1vmin;
color: $color-text;
}
const $nav = document.getElementById('nav-container'),
$body = document.getElementById('body'),
$main = document.getElementById('main'),
$logo = document.getElementById('logo'),
$menu = document.getElementById('menu'),
$title = document.getElementById('title'),
$button = document.getElementById('button'),
$rotate = document.getElementById('rotate'),
$rotateCirc = new CircleType($rotate),
$circ = new CircleType(document.getElementById('circ')),
$circ2 = new CircleType(document.getElementById('circ2')),
$circ3 = new CircleType(document.getElementById('circ3'));
$circ.radius(2);
$circ2.radius(2);
$circ3.radius(2);
$rotateCirc.radius(1);
$menu.addEventListener('click', function () {
$menu.classList.toggle('active');
$logo.classList.toggle('active');
$nav.classList.toggle('active');
});
$button.addEventListener('click', function () {
$body.classList.toggle('active');
});
var maxDist;
var mouse = cursor = {
x: 0,
y: 0
};
Math.dist = function (a, b) {
var dx = b.x - a.x;
var dy = b.y - a.y;
return Math.sqrt(Math.pow(dx, 2), Math.pow(dy, 2));
}
// window.addEventListener("mousedown", function(e) {
$body.onmousemove = function (e) {
// var id = e.target.id;
// console.log('target: ' + e.target.id);
// if(id == 'title') {
cursor.x = e.clientX;
cursor.y = e.clientY;
// working
// }
// console.log(e.clientX);
// console.log(e.clientY);
}
// });
// window.addEventListener("mouseup", function(e){
// window.onmousemove = null;
// // cursor.x = 0;
// // cursor.y = 0;
// });
window.addEventListener("touchmove", function (e) {
var t = e.touches[0];
cursor.x = t.clientX;
cursor.y = t.clientY;
}, {
passive: false
});
var Char = function (container, char) {
var span = document.createElement("span");
span.setAttribute('data-char', char);
span.innerText = char;
container.appendChild(span);
this.getDist = function () {
this.pos = span.getBoundingClientRect();
return Math.dist(cursor, {
x: this.pos.x + (this.pos.width / 1.75),
y: this.pos.y
});
}
this.getAttr = function (dist, min, max) {
var wght = max - Math.abs((max * dist / maxDist));
return Math.max(min, wght + min);
}
this.update = function (args) {
var dist = this.getDist();
this.wdth = args.wdth ? ~~this.getAttr(dist, 5, 200) : 100;
this.wght = args.wght ? ~~this.getAttr(dist, 100, 800) : 400;
this.alpha = args.alpha ? this.getAttr(dist, 0, 1).toFixed(2) : 1;
this.ital = args.ital ? this.getAttr(dist, 0, 1).toFixed(2) : 0;
this.draw();
}
this.draw = function () {
var style = "";
style += "opacity: " + this.alpha + ";";
style += "font-variation-settings: 'wght' " + this.wght + ", 'wdth' " + this.wdth + ", 'ital' " + this.ital + ";";
span.style = style;
}
return this;
}
var VFont = function () {
this.scale = false;
this.flex = false;
this.alpha = false;
this.stroke = true;
this.width = true;
this.weight = true;
this.italic = true;
var title, str, chars = [];
this.init = function () {
title = document.getElementById("title");
str = title.innerText;
title.innerHTML = "";
for (var i = 0; i < str.length; i++) {
var _char = new Char(title, str[i]);
chars.push(_char);
}
this.set();
window.addEventListener("resize", this.setSize.bind(this));
}
this.set = function () {
title.className = "";
title.className += this.flex ? " flex" : "";
title.className += this.stroke ? " stroke" : "";
this.setSize();
}
this.setSize = function () {
var fontSize = window.innerWidth / str.length * 1.7;
title.style = "font-size: " + fontSize + "px;";
if (this.scale) {
var scaleY = (window.innerHeight / title.getBoundingClientRect().height).toFixed(2);
var lineHeight = scaleY * 0.8;
title.style = "font-size: " + fontSize + "px; transform: scale(1," + scaleY + "); line-height: " + lineHeight + "em;"
}
}
this.animate = function () {
mouse.x += (cursor.x - mouse.x) / 5;
mouse.y += (cursor.y - mouse.y) / 5;
requestAnimationFrame(this.animate.bind(this));
this.render();
}
this.render = function () {
maxDist = title.getBoundingClientRect().width / 2;
for (var i = 0; i < chars.length; i++) {
chars[i].update({
wght: this.weight,
wdth: this.width,
ital: this.italic,
alpha: this.alpha
});
}
}
this.init();
this.animate();
return this;
}
var txt = new VFont();
// var gui = new dat.GUI();
// gui.add(txt, 'flex').onChange(txt.set.bind(txt));
// gui.add(txt, 'scale').onChange(txt.set.bind(txt));
// gui.add(txt, 'alpha').onChange(txt.set.bind(txt));
// gui.add(txt, 'stroke').onChange(txt.set.bind(txt));
// gui.add(txt, 'width').onChange(txt.set.bind(txt));
// gui.add(txt, 'weight').onChange(txt.set.bind(txt));
// gui.add(txt, 'italic').onChange(txt.set.bind(txt));
///////////////////////////////
// -------- drag --------- //
///////////////////////////////
(function() {
var init,
start, stop, move,
_x, _y,
active = false,
drag = document.getElementById('drag'),
d = document.getElementById('draggable'),
con = $body;
init = function() {
// Mouse Events
drag.addEventListener('mousedown', start, false);
$(document).bind('mousemove', function(event) {
if (active === true) {
move(event);
}
});
$(document).bind('mouseup', function(event) {
stop(event.originalEvent);
});
};
start = function(e) {
e.preventDefault();
// mouse pos
var Mx = e.clientX,
My = e.clientY,
l = d.getBoundingClientRect().left,
t = d.getBoundingClientRect().top;
// offset
_x = Mx - l;
_y = My - t;
return active = true;
};
move = function(e) {
e.preventDefault();
var Mx = e.clientX,
My = e.clientY,
l = d.getBoundingClientRect().left,
t = d.getBoundingClientRect().top,
w = d.getBoundingClientRect().width,
h = d.getBoundingClientRect().height,
_l = con.getBoundingClientRect().left,
_t = con.getBoundingClientRect().top,
_w = con.getBoundingClientRect().width,
_h = con.getBoundingClientRect().height,
x, y;
//check to see if mouse is inside container
if (Mx - _x > _l && Mx + w - _l < _w + _x) {
// x = mouseX - offsetX - containerX
x = Mx - _x - _l ;
}
if (My - _y > _t && My + h - _t < _h + _y) {
// y = mouseY - offsetY - containerY
y = My - _y - _t;
}
return d.style.left = x + 'px', d.style.top = y + 'px';
};
stop = function() {
return active = false;
};
init();
}).call(this);
///////////////////////////////
// ------- rotate -------- //
///////////////////////////////
(function() {
var init, rotate, start, stop,
active = false,
angle = 0,
rotation = 0,
startAngle = 0,
center = {
x: 0,
y: 0
},
R2D = 180 / Math.PI,
rot = document.getElementById('rotate');
init = function() {
rot.addEventListener("mousedown", start, false);
$(document).bind('mousemove', function(event) {
if (active === true) {
event.preventDefault();
rotate(event);
}
});
$(document).bind('mouseup', function(event) {
event.preventDefault();
stop(event);
});
};
start = function(e) {
e.preventDefault();
var bb = this.getBoundingClientRect(),
t = bb.top,
l = bb.left,
h = bb.height,
w = bb.width,
x, y;
center = {
x: l + (w / 2),
y: t + (h / 2)
};
x = e.clientX - center.x;
y = e.clientY - center.y;
startAngle = R2D * Math.atan2(y, x);
return active = true;
};
rotate = function(e) {
e.preventDefault();
var x = e.clientX - center.x,
y = e.clientY - center.y,
d = R2D * Math.atan2(y, x);
rotation = d - startAngle;
return rot.style.webkitTransform = "rotate(" + (angle + rotation) + "deg)";
};
stop = function() {
angle += rotation;
return active = false;
};
init();
}).call(this);
Also see: Tab Triggers