css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

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');
  });
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console