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 method="post" action="https://basket.step.rakuten.co.jp/rms/mall/bs/cartadd/set" target="_blank" class="cart">
<input value="店舗id" type="hidden" name="shop_bid">
<input value="商品id" type="hidden" name="item_id">
<label for="units">個数</label>
<div class="input_area">
<input type="number" class="counter1" aria-label="個数" aria-describedby="units" value="1" maxlength="3" min="1" max="999" data-min="1" data-max="999" pattern="d*" name="units" id="units">
<button type="button" class="btnspinner" data-cal="-1" data-target=".counter1" style="margin-left: auto;">-</button>
<button type="button" class="btnspinner" data-cal="1" data-target=".counter1" style="margin-left: 7px;">+</button>
</div>
<button type="submit"><svg class="svg-icon" viewBox="0 0 20 20">
<path
d="M14.613,10c0,0.23-0.188,0.419-0.419,0.419H10.42v3.774c0,0.23-0.189,0.42-0.42,0.42s-0.419-0.189-0.419-0.42v-3.774H5.806c-0.23,0-0.419-0.189-0.419-0.419s0.189-0.419,0.419-0.419h3.775V5.806c0-0.23,0.189-0.419,0.419-0.419s0.42,0.189,0.42,0.419v3.775h3.774C14.425,9.581,14.613,9.77,14.613,10 M17.969,10c0,4.401-3.567,7.969-7.969,7.969c-4.402,0-7.969-3.567-7.969-7.969c0-4.402,3.567-7.969,7.969-7.969C14.401,2.031,17.969,5.598,17.969,10 M17.13,10c0-3.932-3.198-7.13-7.13-7.13S2.87,6.068,2.87,10c0,3.933,3.198,7.13,7.13,7.13S17.13,13.933,17.13,10">
</path>
</svg>商品をかごに追加</button>
</form>
/* ラベル */
.cart label {
font-size: .8rem;
letter-spacing: .12em;
display: inline-block;
margin-bottom: .5rem;
}
.input_area {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 1.8rem;
}
/* 個数入力エリア */
.input_area input {
font-size: 1rem;
padding: .6rem;
background-color: #f5f5f5;
border: none;
box-shadow: 0 2px 0 0 #808080;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
font-size: 1.2rem;
}
.input_area input:focus {
outline: 0;
}
/* FireFox,IEのデフォルトのスピナーを消す */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Chrome、Safariのデフォルトのスピナーを消す */
input[type="number"] {
-moz-appearance: textfield;
}
/* 個数増減ボタン */
.btnspinner {
background-color: white;
padding: .6rem .85rem;
border: 1px solid #ccc;
border-radius: 4px;
cursor: pointer;
/* テキストを選択できないようにする */
-ms-user-select: none;
-moz-user-select: -moz-none;
-khtml-user-select: none;
-webkit-user-select: none;
user-select: none;
}
.btnspinner:hover {
background-color: #f8f9fa;
}
.btnspinner:focus {
outline: 0;
border-color: #6c757d;
box-shadow: 0 0 0 0.2rem rgba(108, 117, 125, .5);
}
/* 商品をかごに追加ボタン */
button[type="submit"] {
width: 100%;
padding: .9em .5em;
border-radius: 4px;
background-color: rgb(191, 0, 0);
color: white;
border: none;
letter-spacing: .12em;
cursor: pointer;
display: inline-flex;
justify-content: center;
}
button[type="submit"]:hover {
background-color: rgba(191, 0, 0, .95);
}
button[type="submit"]:focus {
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, .5);
}
/* SVGアイコン */
.svg-icon {
width: 1.4em;
height: 1.4em;
margin-right: .3em;
vertical-align: text-bottom
}
.svg-icon path,
.svg-icon polygon,
.svg-icon rect {
fill: #fff
}
.svg-icon circle {
stroke: #fff;
stroke-width: 1
$(function() {
var arySpinnerCtrl = [];
var spin_speed = 20; //変動スピード
//長押し押下時
$('.btnspinner').on('touchstart mousedown click', function(e) {
if (arySpinnerCtrl['interval']) return false;
var target = $(this).data('target');
arySpinnerCtrl['target'] = target;
arySpinnerCtrl['timestamp'] = e.timeStamp;
arySpinnerCtrl['cal'] = Number($(this).data('cal'));
//クリックは単一の処理に留める
if (e.type == 'click') {
spinnerCal();
arySpinnerCtrl = [];
return false;
}
//長押し時の処理
setTimeout(function() {
//インターバル未実行中 + 長押しのイベントタイプスタンプ一致時に計算処理
if (!arySpinnerCtrl['interval'] && arySpinnerCtrl['timestamp'] == e.timeStamp) {
arySpinnerCtrl['interval'] = setInterval(spinnerCal, spin_speed);
}
}, 500);
});
//長押し解除時 画面スクロールも解除に含む
$(document).on('touchend mouseup scroll', function(e) {
if (arySpinnerCtrl['interval']) {
clearInterval(arySpinnerCtrl['interval']);
arySpinnerCtrl = [];
}
});
//変動計算関数
function spinnerCal() {
var target = $(arySpinnerCtrl['target']);
var num = Number(target.val());
num = num + arySpinnerCtrl['cal'];
if (num > Number(target.data('max'))) {
target.val(Number(target.data('max')));
} else if (Number(target.data('min')) > num) {
target.val(Number(target.data('min')));
} else {
target.val(num);
}
}
}
);
Also see: Tab Triggers