JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
HTML Settings
Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.
<div style="margin: 0 auto; width: 80%;">
<h1>overflow でスクロールバーを表示させると padding-right・padding-bottom が効かなくなる事象と対策</h1>
<h2>通常版</h2>
<pre class="normal">Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br><br><br><br><br>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</pre>
<h2>修正版 <input type="button" id="toggle" value="疑似要素表示切替" style="float: right;"></h2>
<div class="fixed">
<pre>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<br><br><br><br><br>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</pre>
</div>
<p>Author : <a href="http://neo.s21.xrea.com/">Neo</a></p>
</div>
*, *::before, *::after { box-sizing: border-box; }
body { overflow-y: scroll; }
h1 { font-size: 1.4rem; margin-top: 0; }
h2 { font-size: 1.1rem; margin-bottom: 0; }
pre { margin: 0; }
/* 通常版 : Firefox だと padding-right・padding-bottom が効かなくなる */
pre.normal {
width: 100%;
height: 5rem;
overflow: scroll;
border: 1px solid #ccc;
padding: 1rem;
background: #f0f0f0;
}
/* 修正版 : 基本デザインはラッパー側で行う */
div.fixed {
width: 100%;
height: 5rem;
overflow: scroll;
border: 1px solid #ccc;
padding: 1rem 0 0 1rem; /* 余計なバッティングを避けるため、右と下は余白を付けないでおく */
background: #f0f0f0;
}
/* padding-bottom 代わりの要素を作る */
div.fixed::after {
content: "";
display: block;
width: 1px;
height: 1rem; /* padding-bottom にしたい値 */
}
/* 中の pre 要素は inline-block にしておき、末尾に自身の ::after 疑似要素が配置できるようにしておく */
div.fixed > pre {
display: inline-block;
}
/* padding-right 代わりの要素を作る */
div.fixed > pre::after {
content: "";
display: inline-block;
width: 1rem; /* padding-right にしたい値 */
height: 1px;
}
/* テスト用・議事要素に色を付ける */
.fixed-demo::after,
.fixed-demo > pre::after {
background: red;
}
// #toggle ボタンで .fixed 要素に対し .fixed-demo クラスをトグルする
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('toggle').addEventListener('click', () => {
document.querySelector('.fixed').classList.toggle('fixed-demo');
});
});
Also see: Tab Triggers