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.
<body>
<div id="superWrapper">
<div id="langSwitch">
<label><input id="langJa" type="radio" name="lang" value="ja" checked="checked"> 日本語</label>
<label><input id="langEn" type="radio" name="lang" value="en"> English</label>
</div>
<div id="demo">
<img id="mask" src="http://flat.press/entry/smart-select/mask.png" alt="" width="2000" height="2000">
<div id="knooo">
<div id="knooo-glow" class="glow">
<img src="http://flat.press/entry/smart-select/knooo_glow.png" alt="" width="109" height="139">
</div>
<div id="knooo-hat" class="element">
<img src="http://flat.press/entry/smart-select/hat.png" alt="" width="66" height="45">
</div>
<div id="knooo-face" class="element">
<div id="knooo-face-glow" class="glow">
<img src="http://flat.press/entry/smart-select/face_glow.png" alt="" width="100" height="66">
</div>
<div id="knooo-face-face" class="faceElement">
<img src="http://flat.press/entry/smart-select/face_face.png" alt="" width="82" height="66">
</div>
<div id="knooo-eye-l" class="faceElement">
<img src="http://flat.press/entry/smart-select/face_eye_l.png" alt="" width="22" height="22">
</div>
<div id="knooo-eye-r" class="faceElement">
<img src="http://flat.press/entry/smart-select/face_eye_r.png" alt="" width="22" height="22">
</div>
<div id="knooo-mouse" class="faceElement">
<img src="http://flat.press/entry/smart-select/face_mouse.png" alt="" width="100" height="36">
</div>
</div>
<div id="knooo-body" class="element">
<img src="http://flat.press/entry/smart-select/body.png" alt="" width="107" height="77">
</div>
<div id="knooo-hand-l" class="element">
<img src="http://flat.press/entry/smart-select/hand_l.png" alt="" width="27" height="31">
</div>
<div id="knooo-hand-r" class="element">
<img src="http://flat.press/entry/smart-select/hand_r.png" alt="" width="27" height="31">
</div>
<div id="knooo-legs" class="element">
<img src="http://flat.press/entry/smart-select/legs.png" alt="" width="80" height="41">
</div>
</div>
<div id="message">
<div id="messageBody"></div>
</div>
</div>
</div>
</body>
@import "compass/css3";
body {
background: #e7c163;
overflow: hidden;
}
#superWrapper {
position: relative;
max-width: 640px;
width: 100%;
margin: 0 auto;
padding: 20px 0;
object-fit: contain;
}
#langSwitch {
margin: 0 20px 20px 20px;
label {
display: inline-table;
margin-right: 20px;
}
}
#demo {
position: relative;
width: 640px;
height: 640px;
background: #e7c163;
}
#mask {
position: absolute;
top: -630px;
left: -680px;
opacity: 0;
}
#message {
position: absolute;
top: 0;
left: 0;
box-sizing: border-box;
width: 100%;
padding: 20px;
text-align: center;
}
#messageBody {
display: inline-block;
margin: 0 auto;
padding: 15px 20px;
border-radius: 5px;
border-radius: 5px;
background: rgba(0,0,0,.65);
}
#messageBody:after {
position: absolute;
bottom: 5px;
left: 305px;
content: '';
border-top: 15px solid rgba(0,0,0,.65);
border-right: 15px solid transparent;
border-left: 15px solid transparent;
}
#messageBody p {
font-family: HelveticaNeue, Helvetica, '游ゴシック', '游ゴシック体', 'Yu Gothic', YuGothic, 'ヒラギノ角ゴ ProN W3', 'Hiragino Kaku Gothic ProN', 'メイリオ', Meiryo, 'MS Pゴシック', 'MS P Gothic', sans-serif;
font-size: 15px;
line-height: 140%;
max-width: 600px;
margin-bottom: 0;
text-align: left;
text-indent: 0;
color: #ddd;
}
body.en #messageBody p.ja {
display: none;
}
body.ja #messageBody p.en {
display: none;
}
p {
margin: 0;
}
#messageBody p strong {
font-weight: bold;
color: #fff;
}
#messageBody p.right {
text-align: right;
}
#knooo {
position: absolute;
top: 300px;
left: 266px;
width: 109px;
height: 139px;
}
#knooo-glow {
position: absolute;
z-index: 0;
top: 0;
left: 0;
}
#knooo-hat {
position: absolute;
z-index: 0;
top: 0;
left: 21px;
}
#knooo-face {
position: absolute;
z-index: 200;
top: 13px;
left: 4px;
width: 100px;
height: 66px;
}
#knooo-face-glow {
position: absolute;
z-index: 0;
top: 0;
left: 0;
}
#knooo-face-face {
position: absolute;
z-index: 0;
top: 0;
left: 9px;
}
#knooo-face-face {
position: absolute;
z-index: 0;
top: 0;
left: 9px;
}
#knooo-eye-l {
position: absolute;
z-index: 0;
top: 25px;
left: 54px;
}
#knooo-eye-r {
position: absolute;
z-index: 0;
top: 25px;
left: 25px;
}
#knooo-mouse {
position: absolute;
z-index: 0;
top: 30px;
left: 0;
}
#knooo-body {
position: absolute;
z-index: 100;
top: 50px;
left: 1px;
}
#knooo-hand-l {
position: absolute;
z-index: 0;
top: 76px;
left: 82px;
}
#knooo-hand-r {
position: absolute;
z-index: 0;
top: 76px;
left: 0;
}
#knooo-legs {
position: absolute;
z-index: 0;
top: 98px;
left: 14px;
}
.marker {
position: absolute;
z-index: 500;
display: none;
width: 5px;
height: 5px;
background: #e00000;
}
.marker.tr {
top: 0;
right: 0;
}
.marker.tl {
top: 0;
left: 0;
}
.marker.br {
right: 0;
bottom: 0;
}
.marker.bl {
bottom: 0;
left: 0;
}
.marker.active {
display: block !important;
background: #00a8ff;
}
.continue,
.back {
display: inline-block;
padding-top: 0.8em;
color: #fff !important;
}
.continue span {
display: inline-block;
margin-right: 0.5em;
transform: rotate(90deg);
animation-name: 'blink';
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
vertical-align: bottom;
animation-property: opacity;
backface-visibility: visible;
}
.back span {
display: inline-block;
margin-right: 0.5em;
transform: rotate(-90deg);
animation-name: 'blink';
animation-duration: 1s;
animation-timing-function: linear;
animation-iteration-count: infinite;
vertical-align: bottom;
animation-property: opacity;
backface-visibility: visible;
}
.glow {
animation-name: 'blink';
animation-duration: .75s;
animation-timing-function: linear;
animation-iteration-count: infinite;
animation-property: opacity;
backface-visibility: visible;
}
@keyframes 'blink' {
0% {
opacity: 0;
}
50% {
opacity: 1;
}
100% {
opacity: 0;
}
}
(function () {
$(function () {
var sceneNum = 0;
var $mask = $('#mask');
var $knooo = $('#knooo');
var $knoooGlow = $('#knooo-glow');
var $hat = $('#knooo-hat');
var $body = $('#knooo-body');
var $face = $('#knooo-face');
var $faceGlow = $('#knooo-face-glow');
var $handL = $('#knooo-hand-l');
var $handR = $('#knooo-hand-r');
var $legs = $('#knooo-legs');
var $faceFace = $('#knooo-face-face');
var $faceEyeL = $('#knooo-eye-l');
var $faceEyeR = $('#knooo-eye-r');
var $faceMouse = $('#knooo-mouse');
var $MB = $('#messageBody');
var marker = '<span class="marker tr"></span><span class="marker tl"></span><span class="marker br"></span><span class="marker bl"></span>';
var scene = function (_num) {
switch (_num) {
case 0:
sceneNum = 0;
$knoooGlow.show();
$faceGlow.hide();
$MB.fadeOut()
.queue(function (nxt) {
$(this).html([
'<p class="en">Hi, I’ll show you the great design concept of the Selection Tool UI. At first <strong>click (tap) and select me</strong>.</p>',
'<p class="ja">こんにちは、いまから新しいセレクトツールのUIコンセプトを紹介します。まずは<strong>僕をクリック(タップ)して選択</strong>してください。</p>'
].join(''))
.fadeIn();
$knooo
.append(marker)
.hover(
function () {
$(this).find('span').show();
},
function () {
$(this).find('span').hide();
}
)
.hammer()
.bind('click tap', function () {
$(this).unbind('click tap');
$knoooGlow.hide();
$(this).find('span').addClass('active');
$MB.fadeOut()
.queue(function (nxt) {
$(this).html([
'<p class="en">OK, I was selected. I am <strong>a group object</strong>. Then, please <strong>double-click (pinch out)</strong> me again.</p>',
'<p class="ja">オーケー、選択されました。僕は<strong>グループオブジェクト</strong>です。今度は僕を<strong>ダブルクリック(ピンチアウト)</strong>してください。</p>'
].join(''))
.fadeIn();
nxt();
});
$(this).hammer().bind('dblclick doubletap pinchout', function() {
$(this).unbind('dblclick doubletap pinchout');
scene(1);
});
});
nxt();
});
break;
case 1:
$knooo.find('.tl').transition({ x: -135, y: -120, duration: 300, easing: 'out'});
$knooo.find('.tr').transition({ x: 135, y: -120, duration: 300, easing: 'out'});
$knooo.find('.bl').transition({ x: -135, y: 120, duration: 300, easing: 'out'});
$knooo.find('.br').transition({ x: 135, y: 120, duration: 300, easing: 'out'});
$mask.css({ transform: 'scale(2)' })
.transition({ opacity: 0.3, scale: 1.4, duration: 300, delay: 200, easing: 'out'});
$hat.transition({ x: 0, y: '-=104', duration: 300, easing: 'out'});
$face.transition({ x: '+=129', y: '-=52', duration: 300, easing: 'out'});
$body.transition({ x: '+=129', y: '+=57', duration: 300, easing: 'out'});
$handL.transition({ x: '-=41', y: '+=129', duration: 300, easing: 'out'});
$handR.transition({ x: '-=90', y: '+=53', duration: 300, easing: 'out'});
$legs.transition({ x: '-=130', y: '-=124', duration: 300, easing: 'out',
complete: function () {
$MB.fadeOut()
.queue(function (nxt) {
$(this).html([
'<p class="en">Well done! You saw that I was separated. But this is the <strong>temporary</strong> state and I’m <strong>still a group object</strong>. Click “Next” to continue.</p>',
'<p class="ja">体が分解してしまったけれど大丈夫。<strong>一時的</strong>に離れただけで、僕はまだ<strong>グループオブジェクトのまま</strong>です。この続きを見るには”Next”をクリックしてください。</p>',
'<p class="right"><a class="continue" href="#"><span>▲</span>Next</a>'
].join(''))
.fadeIn();
$knooo.unbind("mouseenter").unbind("mouseleave");
$MB.find('.continue').click(function () {
$(this).unbind('click');
scene(2);
});
nxt();
});
}
});
break;
case 2:
$knooo.find('.element')
.append(marker)
.hover(
function () {
$(this).find('span').show();
},
function () {
$(this).find('span').hide();
}
)
.hammer()
.bind('click tap', function () {
$('#knooo > .marker').remove();
$knooo.find('.element > span').removeClass('active');
$(this).find('span').addClass('active');
});
$MB.fadeOut()
.queue(function (nxt) {
$faceGlow.show();
$(this).html([
'<p class="en">In this state, you can select one of bodies’ object. You need NOT ungroup me to select the object <strong>in lower layer</strong>. <strong>Let’s select the FACE object</strong>.</p>',
'<p class="ja">この状態で僕の体のオブジェクトを選択することもできます。<strong>下層のオブジェクトを選択するために、わざわざグループオブジェクトを解除する必要はない</strong>よ。次は僕の「<strong>顔</strong>」を選んでみてください。</p>'
].join(''))
.fadeIn();
$face.hammer().bind('click tap', function () {
$knooo.find('.element').unbind();
$faceGlow.hide();
scene(3);
});
nxt();
});
break;
case 3:
$MB.fadeOut()
.queue(function (nxt) {
$(this).html([
'<p class="en">OK. Now you selected my face, and it’s also <strong>a group object</strong>. If you wanted to finish the Smart Selection Tool, <strong>click the margin or pinch in</strong>. OR, if you <strong>double-click (pinch out) my face</strong>...!?</p>',
'<p class="ja">ありがとう、いまあなたは僕の顔を選択してます。僕の顔もまた<strong>グループオブジェクト</strong>だよ。このままスマートセレクトから抜けるには、<strong>空白部分をクリックするかピンチイン</strong>してください。または僕の顔をさらに<strong>ダブルクリック(ピンチアウト)</strong>すると...!?</p>'
].join(''))
.fadeIn();
$('#demo').hammer().bind('click pinchin', function (event) {
$(this).unbind('click pinchin');
$knooo.find('.element').unbind();
scene(4);
});
$knooo.find('.element').click(function (event) {
event.preventDefault();
event.stopPropagation();
});
$face.hammer().bind('dblclick doubletap pinchout', function (event) {
$('#demo').unbind();
$knooo.find('.element').unbind();
scene(5);
});
nxt();
});
break;
case 4:
$mask.transition({ opacity: 0, scale: 0.2, duration: 300, delay: 200, easing: 'out'});
$hat.transition({ x: 0, y: '+=104', duration: 300, easing: 'out'});
$face.transition({ x: '-=129', y: '+=52', duration: 300, easing: 'out'});
$body.transition({ x: '-=129', y: '-=57', duration: 300, easing: 'out'});
$handL.transition({ x: '+=41', y: '-=129', duration: 300, easing: 'out'});
$handR.transition({ x: '+=90', y: '-=53', duration: 300, easing: 'out'});
$legs.transition({ x: '+=130', y: '+=124', duration: 300, easing: 'out',
complete: function () {
$MB.fadeOut()
.queue(function (nxt) {
$knoooGlow.hide();
$(this).html([
'<p class="en">Hi, you came back to the first state. <strong>You selected my face object without ungroup me!</strong> If you wanted to try it again, click the ”Back”.</p>',
'<p class="ja">これで最初の状態に戻りました。<strong>グループ化を解かずに僕の顔を選択できました</strong>ね。もう一度試すには“Back”をクリックしてね。</p>',
'<p class="right"><a class="back" href="#"><span>▲</span>Back</a></p>'
].join(''))
.fadeIn();
$MB.find('.back').click(function () {
$(this).unbind('click');
$knooo.find('.marker').remove();
scene(0);
});
nxt();
});
}
});
break;
case 5:
$mask.transition({ scale: 0.3, opacity: 0.1, duration: 300, easing: 'out'});
$face.transition({ x: 4, y: 37, duration: 300, easing: 'out',
complete: function () {
$mask.transition({ scale: 1.4, opacity: 0.3, duration: 300, delay: 200, easing: 'out'});
$face.find('.tl').transition({ x: -140, y: -157, duration: 300, easing: 'out'});
$face.find('.tr').transition({ x: 140, y: -157, duration: 300, easing: 'out'});
$face.find('.bl').transition({ x: -140, y: 157, duration: 300, easing: 'out'});
$face.find('.br').transition({ x: 140, y: 157, duration: 300, easing: 'out'});
$faceFace.transition({ x: 0, y: '-=151', duration: 300, easing: 'out'});
$faceEyeL.transition({ x: '+=135', y: '-=3', duration: 300, easing: 'out'});
$faceEyeR.transition({ x: '+=14', y: '+=147', duration: 300, easing: 'out'});
$faceMouse.transition({ x: '-=150', y: '-=16', duration: 300, easing: 'out',
complete: function () {
scene(6);
}
});
}
});
$hat.transition({ opacity: 0, duration: 300, easing: 'out'});
$body.transition({ opacity: 0, duration: 300, easing: 'out'});
$handL.transition({ opacity: 0, duration: 300, easing: 'out'});
$handR.transition({ opacity: 0, duration: 300, easing: 'out'});
$legs.transition({ opacity: 0, duration: 300, easing: 'out'});
break;
case 6:
$MB.fadeOut()
.queue(function (nxt) {
$(this).html([
'<p class="en">Then, I was separated again but it’s not ungrouped. Let’s select one of them.</p>',
'<p class="ja">さらに僕の顔がばらばらになったね。今回もやはりグループは解除されていません。どれかオブジェクトを選んでください。</p>'
].join(''))
.fadeIn();
$knooo.find('.faceElement')
.append(marker)
.hover(
function () {
$(this).find('span').show();
},
function () {
$(this).find('span').hide();
}
)
.hammer()
.bind('click tap', function (event) {
event.preventDefault();
event.stopPropagation();
$('#knooo-face > span').remove();
$knooo.find('.faceElement > span').removeClass('active');
$(this).find('span').addClass('active');
if (sceneNum === 0) {
sceneNum = 7;
scene(7);
}
});
nxt();
});
break;
case 7:
$MB.fadeOut()
.queue(function (nxt) {
$(this).html([
'<p class="en">OK! You could select the object again. Then, <strong>click the margin (or pinch in)</strong> to back to the first state.</p>',
'<p class="ja">オーケーです、オブジェクトを選択できました。もとの状態に戻るために<strong>空白部分をクリックするかピンチイン</strong>しましょう。</p>'
].join(''))
.fadeIn();
$('#demo').hammer().bind('click pinchin', function () {
$(this).unbind('click pinchin');
$face.find('.faceElement').unbind();
$face.unbind();
scene(8);
});
nxt();
});
break;
case 8:
$mask.transition({ opacity: 0, scale: 0.2, duration: 300, delay: 200, easing: 'out'});
$faceFace.transition({ x: 0, y: '+=151', duration: 300, easing: 'out'});
$faceEyeL.transition({ x: '-=135', y: '+=3', duration: 300, easing: 'out'});
$faceEyeR.transition({ x: '-=14', y: '-=147', duration: 300, easing: 'out'});
$faceMouse.transition({ x: '+=150', y: '+=16', duration: 300, easing: 'out',
complete: function () {
$face.transition({ x: 0, y: '-=37', duration: 300, easing: 'out'});
$hat.transition({ opacity: 1, x: 0, y: '+=104', duration: 300, easing: 'out'});
$body.transition({ opacity: 1, x: '-=129', y: '-=57', duration: 300, easing: 'out'});
$handL.transition({ opacity: 1, x: '+=41', y: '-=129', duration: 300, easing: 'out'});
$handR.transition({ opacity: 1, x: '+=90', y: '-=53', duration: 300, easing: 'out'});
$legs.transition({ opacity: 1, x: '+=130', y: '+=124', duration: 300, easing: 'out',
complete: function () {
$MB.fadeOut()
.queue(function (nxt) {
$knoooGlow.hide();
$(this).html([
'<p class="en">Well come back. <strong>You could select the deeper object located in the group</strong>, without ungrouping any group objects.</p>',
'<p class="ja">おかえりなさい。僕のグループ化を解かずに、<strong>2階層の下のオブジェクトを選択することができました</strong>。もう一度試すには“Back”をクリックしてね。</p>',
'<p class="right"><a class="back" href="#"><span>▲</span>Back</a></p>'
].join(''))
.fadeIn();
$MB.find('.back').click(function () {
$(this).unbind('click');
$knooo.find('.marker').remove();
scene(0);
});
nxt();
});
}
});
}
});
break;
}
};
scene(0);
$('#langEn').click(function () {
$('body').addClass('en');
$('body').removeClass('ja');
});
$('#langJa').click(function () {
$('body').addClass('ja');
$('body').removeClass('en');
});
$('body').addClass('ja');
});
})();
Also see: Tab Triggers