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.
%form
%input{type: 'hidden', name: 'queue_id'}
%input{type: 'hidden', name: 'user_id'}
%input{type: 'hidden', name: 'salt'}
%input{type: 'hidden', name: 'iterations'}
%input{type: 'hidden', name: 'passhash'}
#fields
- n = 7
- [{id: 'name', required: true, label: 'Username', type: 'text'},{id: 'given', required: false, label: 'First Name', type: 'text'},{id: 'family', required: false, label: 'Last Name', type: 'text'},{id: 'email', required: true, label: 'Email', type: 'text'},{id: 'email_confirm', required: true, label: 'Confirm Email', type: 'text'},{id: 'password', required: true, label: 'Password', type: 'password'},{id: 'password_confirm', required: true, label: 'Confirm Password', type: 'password'}].each do |field|
.field
%svg{onclick: '$("#text-'+field[:id]+'").focus();'}
%input.box{type: field[:type], size: 25, name: field[:id], id: 'text-'+field[:id], required: field[:required], placeholder: field[:label], autocomplete: 'off'}
%label#logo{for: 'toggle'}
%svg#svglogo{:xmlns => 'http://www.w3.org/2000/svg', :version => '1.1', :pagealignment => 'none', :x => 0, :y => 0, :width => '353.55339', :height => '353.55339', 'enable-background' => 'new 0 0 353.55339 353.55339', :viewbox => '0 0 500 500', 'xml:space' => 'preserve', :bodybackgroundcolor => 'rgba(255,0,0,0)'}
%rect{x: 0, y: 0, width: 500, height: 500, fill: 'none'}
%g{type: 'LAYER', name: 'workspace', locked: 'true'}
%g{type: 'LAYER', name: 'Layer 01'}
%path.circle{transform: 'matrix(1 0 0 1 255.4278416347392 223.4993614303981)', width: '491.7', height: '489.1', 'stroke-miterlimit': '3', d: 'M-252.4 27.4C-252.4-107.7-142.4-217.2-6.6-217.2 129.2-217.2 239.3-107.7 239.3 27.4 239.3 162.5 129.2 272-6.6 272 -142.4 272-252.4 162.5-252.4 27.4Z'}
%path.ow{transform: 'matrix(1 0 0 1 20.434227330779322 57.47126436781617)', width: '472', height: '469.5', 'stroke-miterlimit': '3', d: 'M169.2 421.3C119.9 406.4 49.6 375.8 10.7 284.5 -28.3 193.1 1.1 96.1 42 48.8 82.8 1.6 127.5-34.8 208.6-41.2 289.7-47.6 319.9-5.6 327.5 63.4 337.9 210.7 310.2 349.2 212.2 380.3 244 388.4 273.8 388.1 295.4 383.8 278.9 401.8 252 414.7 210 428.1 293.6 432.6 355 398.8 390 364.9 425.1 331.1 484.3 254.2 458.2 137.8'}
%input.title{type: 'submit', value: 'Submit'}
// imported from http://one-wolf.com/stylesheets/main.css
/* line 3, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/background-main.scss */
html {
width: 100%;
height: 100%;
overflow: hidden;
}
/* line 9, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/background-main.scss */
body {
width: 100%;
height: 100%;
background: #333;
background: -webkit-linear-gradient(bottom, rgba(75, 56, 88, 0.5) 10%, rgba(51, 51, 51, 0) 60%), -webkit-radial-gradient(100% 40%, ellipse, rgba(202, 176, 158, 0.5), rgba(51, 51, 51, 0) 70%), -webkit-radial-gradient(0% 0%, ellipse, rgba(103, 46, 46, 0.7), rgba(51, 51, 51, 0)), black;
background: linear-gradient(to top, rgba(75, 56, 88, 0.5) 10%, rgba(51, 51, 51, 0) 60%), radial-gradient(ellipse at 100% 40%, rgba(202, 176, 158, 0.5), rgba(51, 51, 51, 0) 70%), radial-gradient(ellipse at 0% 0%, rgba(103, 46, 46, 0.7), rgba(51, 51, 51, 0)), black;
}
/* line 4, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/main.scss */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* line 10, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/main.scss */
body {
color: #ddd;
}
/* line 12, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/main.scss */
body a {
color: #88f;
}
/* line 14, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/main.scss */
body a:visited {
color: #c8f;
}
/* line 17, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/main.scss */
body a:active {
color: #f44;
}
/* line 20, /home/ubuntu/rails-apps/OHAlpha/one-wolf/tsume/rails-5.0/One-Wolf.com/app/assets/stylesheets/main.scss */
body a:hover {
color: #f88;
}
// imported from one-wolf/math.scss
@function pow($number, $exp) {
$value: 1;
@if $exp > 0 {
@for $i from 1 through $exp {
$value: $value * $number;
}
}
@else if $exp < 0 {
@for $i from 1 through -$exp {
$value: $value / $number;
}
}
@return $value;
}
@function fact($number) {
$value: 1;
@if $number > 0 {
@for $i from 1 through $number {
$value: $value * $i;
}
}
@return $value;
}
@function sqrt($r) {
$x0: 1; // initial value
$solution: false;
@for $i from 1 through 10 {
@if abs(2 * $x0) < 0,
00000000000001 {
// Don't want to divide by a number smaller than this
$solution: false;
}
$x1: $x0 - ($x0 * $x0 - abs($r)) / (2 * $x0) !global;
@if ( abs($x1 - $x0) / abs($x1)) < 0,
0000001 {
// 7 digit accuracy is desired
$solution: true;
}
$x0: $x1;
}
@if $solution==true {
// If $r is negative, then the output will be multiplied with <a href="http://en.wikipedia.org/wiki/Imaginary_number">i = √-1</a>
// (√xy = √x√y) => √-$r = √-1√$r
@if $r < 0 {
@return $x1 #{i};
}
@else {
@return $x1;
}
}
@else {
@return "No solution";
}
}
@function pi() {
@return 3.14159265359;
}
@function rad($angle) {
$unit: unit($angle);
$unitless: $angle / ($angle * 0 + 1);
// If the angle has 'deg' as unit, convert to radians.
@if $unit==deg {
$unitless: $unitless / 180 * pi();
}
@return $unitless;
}
@function sin($angle) {
$sin: 0;
$angle: rad($angle);
// Iterate a bunch of times.
@for $i from 0 through 10 {
$sin: $sin + pow(-1, $i) * pow($angle, (2 * $i + 1)) / fact(2 * $i + 1);
}
@return $sin / ( $sin * 0 + 1);
}
@function cos($angle) {
$cos: 0;
$angle: rad($angle);
// Iterate a bunch of times.
@for $i from 0 through 10 {
$cos: $cos + pow(-1, $i) * pow($angle, 2 * $i) / fact(2 * $i);
}
@return $cos / ( $cos * 0 + 1);
}
@function tan($angle) {
@return sin($angle) / cos($angle);
}
// pen css
$svglogo-col: rgba(0, 0, 0, .8);
$svglogo-circle-stroke: #ffffff;
$svglogo-ow-stroke: #ffffff;
$svglogo-circle-stroke-width: 3;
$svglogo-ow-stroke-width: 3;
$form-height: 390px;
$form-width: 750px;
#logo {
pointer-events: none;
background: red;
&:hover .title {
content: 'Submit';
box-shadow: 0 0 10px rgba(0, 0, 0, .5);
background-color: white;
color: black;
text-shadow: 1px 1px 10px rgba(0, 0, 0, 0.7);
}
}
#svglogo {
transform: rotate(0);
transition: all 1.5s cubic-bezier(.18, .94, .26, .99);
position: absolute;
left: 20px;
top: 20px;
width: 350px;
height: 350px;
.circle {
pointer-events: visible;
fill: rgba($svglogo-col,.6);
stroke: $svglogo-circle-stroke;
stroke-width: $svglogo-circle-stroke-width;
}
.ow {
pointer-events: visible;
fill: none;
stroke: $svglogo-ow-stroke;
stroke-width: $svglogo-ow-stroke-width;
}
}
.title {
//cursor: pointer;
pointer-events: visible;
color: rgba(0, 0, 0, .54);
position: absolute;
width: 100px;
height: 100px;
top: ( $form-height - 100px) /2;
left: ( $form-height - 100px) /2;
border-radius: 50%;
background-color: rgba(255, 255, 255, .5);
transition: all .75s cubic-bezier(0, 0, .38, 1);
font-size: 20px;
text-align: center;
line-height: 100px;
border: none;
font-family: serif;
}
$num: 7;
$field-height: 350px / $num;
form {
position: absolute;
width: $form-width;
height: $form-height;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
border-radius: 195px;
background: rgba(255,255,255,.8);
background: linear-gradient(to left, rgba(157, 145, 164,.4), transparent 80%);
#fields {
pointer-events: none;
position: absolute;
left: 20px + 175px;
top: 20px;
right: 0;
bottom: 20px;
.field {
pointer-events: none;
position: absolute;
left: 0;
top: 0;
right: 0;
height: $field_height;
svg {
position: absolute;
pointer-events: visible;
left: 0;
top: 0;
width: 100%;
height: 100%;
.arctext {
pointer-events: visible;
cursor: text;
fill: rgba(55, 33, 69, .6);
stroke: rgba(124, 108, 135, .4);
stroke-width: 3px;
}
}
$input-padding: 20px;
input.box {
pointer-events: visible;
display: block;
position: absolute;
top: $input-padding / 2;
height: $field-height - $input-padding;
padding: 10px;
border: 1px solid rgba(103, 69, 46,0.8);
outline: none;
border-radius: 5px;
background: rgba(86, 38, 61, .9);
box-shadow: inset 0 -5px 45px rgba(202, 176, 158,0.2), 0 1px 1px rgba(255,255,255,0.2);
text-shadow: 1px 1px 1px rgba(0,0,0,0.3);
&:focus {
border: 1px solid transparent;
box-shadow: inset 0 -5px 45px rgba(246, 228, 216,0.4), 0 1px 1px rgba(255,255,255,0.2);
}
}
$input-radius: 200;
$input-square: $input-radius * $input-radius;
@for $index from 0 to $num {
&:nth-child(#{$index+1}) {
$top: 185 - (10 + $index * $field_height/1px + 2.5);
$bottom: 185 - (10 + ($index + 1) * $field_height/1px + 2.5);
$left: 0;
$right: 0;
@if $top * $bottom > 0 {
@if $top > 0 {
$left: #{sqrt($input-square - $bottom * $bottom)}px;
$right: #{sqrt($input-square - $top * $top)}px + 750px - 40px - 350px;
}
@else {
$left: #{sqrt($input-square - $top * $top)}px;
$right: #{sqrt($input-square - $bottom * $bottom)}px + 750px - 40px - 350px;
}
}
@else {
$left: #{$input-radius}px;
$right: #{sqrt($input-square - $top * $top)}px + 750px - 40px - 350px;
}
top: $index * $field-height;
input.box {
left: $left;
width: $right - $left;
}
}
}
}
}
}
function rotj(p, angle) {
return [
p[0] * Math.cos(angle) - p[1] * Math.sin(angle),
p[0] * Math.sin(angle) + p[1] * Math.cos(angle)
];
}
function b_points(c, s, p, angle) {
var ps = rotj(p, angle);
return [
c[0] + s[0] * ps[0],
c[1] - s[1] * ps[1]
];
}
function b_to(c, s, t, p, angle) {
var ps = b_points(c, s, p, angle);
return t + ps[0] + ',' + ps[1];
}
function arc_points(c, s, theta, phi) {
var ps = [
[-Math.sin(theta),
Math.cos(theta)
],
[
((Math.cos(theta) - 1) * (3 - Math.cos(theta))) / (3 * Math.sin(theta)),
(4 - Math.cos(theta)) / 3
]
];
return [
rotj(ps[0], phi),
rotj(ps[1], phi),
rotj([-ps[1][0], ps[1][1]], phi),
rotj([-ps[0][0], ps[0][1]], phi)
];
}
function arc_to(c, s, theta, phi) {
var psr = arc_points(c, s, theta, phi);
return 'C' + (c[0] + s[0] * psr[1][0]) + ',' + (c[1] - s[1] * psr[1][1]) +
' ' + (c[0] + s[0] * psr[2][0]) + ',' + (c[1] - s[1] * psr[2][1]) +
' ' + (c[0] + s[0] * psr[3][0]) + ',' + (c[1] - s[1] * psr[3][1]);
}
$(function() {
var n = 7;
var fields_height = 350;
var fields_radius = fields_height / 2;
var field_height = fields_height / n;
var c1 = [0,fields_radius];
var c2 = [750 - 40 - 350,fields_radius];
var r1 = 185;
var s1 = [r1,r1];
var r2 = 175;
var s2 = [r2,r2];
var v = 0;
var tol = .02;
for (var i = 0; i < n; i++) {
var svg = 'form #fields .field:nth-child(' + (i + 1) + ') svg';
var snap = Snap(svg);
var origin = i * field_height;
var c1t = [c1[0],c1[1]-origin];
var c2t = [c2[0],c2[1]-origin];
var top = fields_radius - (i * field_height + 2.5);
var bottom = fields_radius - ((i + 1) * field_height - 2.5);
var at1 = Math.asin(top / r1);
var ab1 = Math.asin(bottom / r1);
var at2 = Math.asin(top / r2);
var ab2 = Math.asin(bottom / r2);
var ar1 = (at1 - ab1) / 2;
var am1 = (at1 + ab1) / 2;
var ar2 = (at2 - ab2) / 2;
var am2 = (at2 + ab2) / 2;
//console.log(top+', '+bottom);
//console.log(at1+', '+ab1+', '+ar1+', '+am1);
//console.log(at2+', '+ab2+', '+ar2+', '+am2);
var z1 = b_to(c1t, s1, 'M', [0,1], at1 - Math.PI / 2);
var z2 = arc_to(c1t, s1, ar1, am1 - Math.PI / 2);
var z3 = b_to(c2t, s2, 'L', [0,1], ab2 - Math.PI / 2);
var z4 = arc_to(c2t, s2, -ar2, am2 - Math.PI / 2);
var path = z1+' '+z2+' '+z3+' '+z4 + ' Z';
//console.log(path);
var path = snap.path(path);
path.attr({
class: 'arctext'
});
}
});
Also see: Tab Triggers