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.
<header>
<h2>Radial Slider</h2>
<p>A radial slider, made with CSS3 and jQuery, Enjoy!</p>
<p>By <a href="http://adrianquevedo.com" target="_blank">Adrian Quevedo</a></p>
<footer class="footer">
<p>© 2002 - 2011 Nintendo. The Legend of Zelda is a trademark of Nintendo. © 2011 Nintendo.</p>
</footer>
</header>
<section>
<div class="knob-slider">
<div class="knob">
<p class="instructions">Drag the knob to see the illustrations</p>
</div>
<div class="knob-circle">
<div class="circle c01"><img src="https://dl.dropboxusercontent.com/u/2402696/codepen-demos/radial-slider/assets/i/link-green.png" alt="Green Link"></div>
<div class="circle c02"><img src="https://dl.dropboxusercontent.com/u/2402696/codepen-demos/radial-slider/assets/i/link-red.png" alt="Red Link"></div>
<div class="circle c03"><img src="https://dl.dropboxusercontent.com/u/2402696/codepen-demos/radial-slider/assets/i/link-blue.png" alt="Blue Link"></div>
<div class="circle c04"><img src="https://dl.dropboxusercontent.com/u/2402696/codepen-demos/radial-slider/assets/i/link-magenta.png" alt="Purple Link"></div>
</div>
</div>
</section>
@import url(https://fonts.googleapis.com/css?family=Shadows+Into+Light+Two);
html {
background-color: #212121; }
a:link,
a:visited {
color: white;
}
header {
background-color: black;
color: white;
font-size: 14px;
height: 200px;
left: 20px;
line-height: 160%;
padding: 25px;
position: fixed;
top: 20px;
width: 200px;
z-index: 99
}
section {
height: 600px;
left: 40px;
position: relative;
top: 150px;
}
.green-glow {
box-shadow: 0 0 150px #5A8F57; }
.red-glow {
box-shadow: 0 0 150px #AD030A; }
.blue-glow {
box-shadow: 0 0 150px #3E73B0; }
.purple-glow {
box-shadow: 0 0 150px #A839A1; }
.knob-slider {
position: relative;
height: 500px;
margin: 0 auto;
width: 500px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.knob {
border: solid 1px #ccc;
border-radius: 50%;
box-shadow: 0 0 2px #333;
cursor: -moz-grab;
cursor: -webkit-grab;
height: 50px;
opacity: .6;
position: absolute;
left: 0;
top: 0;
width: 50px;
z-index: 99;
background-color: rgba(255, 255, 255, 0);
background-image: -webkit-gradient(radial, center center, 0, center center, 460, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, white), color-stop(100%, white));
background-image: -webkit-radial-gradient(center, ellipse, rgba(255, 255, 255, 0) 0%, white 100%, white);
background-image: radial-gradient( ellipse at center, rgba(255, 255, 255, 0) 0%, white 100%, white);
-webkit-transition: opacity 0.2s ease-in-out;
-moz-transition: opacity 0.2s ease-in-out;
transition: opacity 0.2s ease-in-out;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.knob:hover {
box-shadow: 0 0 5px #666;
opacity: 1; }
.knob.grab {
cursor: -moz-grabbing;
cursor: -webkit-grabbing; }
.instructions {
color: white;
font-family: 'Shadows Into Light Two', cursive;
right: 40px;
position: absolute;
text-align: center;
width: 150px;
-webkit-transform: rotate(-45deg);
-ms-transform: rotate(-45deg);
-o-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
transform: rotate(-45deg);
}
.knob-circle {
background: #18161e url(https://dl.dropboxusercontent.com/u/2402696/codepen-demos/radial-slider/assets/i/circle-bg.png) center no-repeat;
border: solid 5px #000;
border-radius: 50%;
cursor: pointer;
height: 100%;
overflow: hidden;
position: relative;
width: 100%;
-webkit-background-clip: padding-box;
background-clip: padding-box;
position: relative;
-webkit-transition: box-shadow 1s ease-in-out;
-moz-transition: box-shadow 1s ease-in-out;
transition: box-shadow 1s ease-in-out;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.circle {
border-radius: 50%;
display: block;
height: 500px;
opacity: 0;
overflow: hidden;
position: absolute;
width: 500px;
-webkit-transition: -webkit-transform .3s ease-in-out;
-moz-transition: -moz-transform .3s ease-in-out;
transition: transform .3s ease-in-out;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none; }
.circle img {
border-radius: 50%; }
.footer {
color: white;
font-size: 8px;
text-align: center; }
.footer p {
line-height: 140%; }
var RS = RS || {};
RS.Site = (function(){
'use strict';
$(document).on('ready', function(){
var RadialSlider = {
containerObject: {},
knobObject: {},
knobCircle: null,
dragging: null,
init: function ($container, $knob, $kCircle) {
//Define the Container Object
this.containerObject.element = $container;
this.containerObject.offsetTop = this.containerObject.element.offset().top;
this.containerObject.offsetLeft = this.containerObject.element.offset().left;
this.containerObject.height = this.containerObject.element.outerHeight()/2;
this.containerObject.width = this.containerObject.element.outerWidth()/2;
this.containerObject.centerX = this.containerObject.offsetLeft + this.containerObject.width;
this.containerObject.centerY = this.containerObject.offsetTop + this.containerObject.height;
//Define the Knob Object
this.knobObject.element = $knob.attr('unselectable', 'on').css('transformOrigin', this.containerObject.width+'px '+ this.containerObject.height+'px');
this.knobObject.height = this.knobObject.element.outerHeight()/2;
this.knobObject.width = this.knobObject.element.outerWidth()/2;
this.knobObject.posX = - this.knobObject.width;
this.knobObject.posY = this.containerObject.height - this.knobObject.height;
//Define Knob Circle
this.knobCircle = $kCircle.attr('unselectable', 'on').addClass('green-glow');
this.knobCircle.find('img').attr('draggable', 'false');
//Actions
this.bindUIActions();
this.rotateKnob(45);
this.slideCircle(0);
},
bindUIActions: function () {
var _this = this;
document.onselectstart = function () { return false; };
$(document.body).on('mousemove', function(e) {
var
newPageX = -1 * (e.pageX - _this.containerObject.centerX),
newPageY = -1 * (e.pageY - _this.containerObject.centerY);
if (_this.dragging) {
var
deg = Math.floor(_this.calculatePolar(newPageX, newPageY));
$('.instructions').fadeOut('fast');
_this.rotateKnob(deg);
_this.slideCircle(deg);
}
});
$(document.body).on('mousedown', '.knob', function (e) {
_this.dragging = $(e.target);
_this.knobObject.element.addClass('grab');
});
$(document.body).on('mouseup', function () {
_this.dragging = null;
_this.knobObject.element.removeClass('grab');
});
_this.knobCircle.on('click', function(e) {
var
newPageX = -1 * (e.pageX - _this.containerObject.centerX),
newPageY = -1 * (e.pageY - _this.containerObject.centerY),
deg = Math.floor(_this.calculatePolar(newPageX, newPageY));
$('.instructions').fadeOut('fast');
_this.rotateKnob(deg);
_this.slideCircle(deg);
e.preventDefault();
});
},
calculatePolar: function (valX, valY) {
var
x = valX,
y = valY,
theta = Math.atan(y/x)*360/2/Math.PI;
if (x >= 0 && y >= 0) {
theta = theta;
} else if (x < 0 && y >= 0) {
theta = 180 + theta;
} else if (x < 0 && y < 0) {
theta = 180 + theta;
} else if (x > 0 && y < 0) {
theta = 360 + theta;
}
return theta;
},
slideCircle: function (deg) {
var $kCircle = this.knobCircle;
$kCircle.children().css({
'transform': 'translate3d(-500px,0,0)'
});
$kCircle.attr('class', 'knob-circle');
if(deg >= 0 && deg < 90) {
$kCircle.addClass('green-glow');
$('.circle:nth-child(1)').css({
'transform': 'translate3d(0,0,0)',
opacity: 1
});
$('.circle:nth-child(2)').css({
'transform': 'translate3d(500px,0,0)',
opacity: 0
});
} else if(deg >= 90 && deg < 180) {
$kCircle.addClass('red-glow');
$('.circle:nth-child(2)').css({
'transform': 'translate3d(0,0,0)',
opacity: 1
});
$('.circle:nth-child(3)').css({
'transform': 'translate3d(500px,0,0)',
opacity: 0
});
} else if(deg >= 180 && deg < 270) {
$kCircle.addClass('blue-glow');
$('.circle:nth-child(3)').css({
'transform': 'translate3d(0,0,0)',
opacity: 1
});
$('.circle:nth-child(4)').css({
'transform': 'translate3d(500px,0,0)',
opacity: 0
});
} else if(deg >= 270 && deg < 360) {
$kCircle.addClass('purple-glow');
$('.circle:nth-child(4)').css({
'transform': 'translate3d(0,0,0)',
opacity: 1
});
$('.circle:nth-child(1)').css({
'transform': 'translate3d(500px,0,0)',
opacity: 0
});
}
},
rotateKnob: function (deg) {
this.knobObject.element.css('transform','rotate('+deg+'deg) translate('+ this.knobObject.posX +'px, '+ this.knobObject.posY +'px)');
}
};
var
$container = $('.knob-slider'),
$knob = $('.knob'),
$kCircle = $('.knob-circle');
RadialSlider.init($container, $knob, $kCircle);
});
}());
Also see: Tab Triggers