Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource


Babel includes JSX processing.

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


Add Packages

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.


Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="switching">
  <div class="switching__content-box">
    <div class="switching__content js-randomSwitching">
      <div class="switching__content-inner">
        <p class="switching__content-text">確率で切り替え有り</p>
    <div class="switching__content">
      <div class="switching__content-inner">
        <p class="switching__content-text">確率で切り替え無し</p>
    <div class="switching__content js-randomSwitching">
      <div class="switching__content-inner">
        <p class="switching__content-text">確率で切り替え有り</p>
  </div><!-- /.switching__contentBox -->
</div><!-- /.switching -->


.switching__content-box {
  height: 100vh;

.switching__content {
  width: 100%;
  height: 33.33%;

.switching__content:nth-child(odd) {
  background-color: rgba(32, 47, 85, 0.3);

.switching__content-inner {
  display: table;
  width: 100%;
  height: 100%;

.switching__content-text {
  display: table-cell;
  font-size: 30px;
  text-align: center;
  vertical-align: middle;

/* 切り替え後 */ {
  color: #ffffff;
  background-color: #202f55;
  transition: all 1s ease 0s;



                // random switching
(function () {
  // 即時実行関数(グローバル汚染対策)
  let i = 0; // for文用変数の定義
  let el = {}; // 配列・変数用(巻き上げ防止の為、冒頭にて宣言)

    function () {
      el.randomSwitching = document.querySelectorAll(".js-randomSwitching"); // 対象セレクタ取得

      // 1~100のランダムな数値を返す
      el.random = Math.floor(Math.random() * 100);

      // ランダムな数値が何(ifの括弧の中の右の数値)以下かを判定する
      if (el.random <= 20) {
        randomSwitchFnc(); // 条件を満たしていればこちらの関数処理を実行する
      } else {
        // 条件を満たしていなければしたい処理はこちらに記述する

      // ランダム切り替え用関数
      function randomSwitchFnc() {
        // 該当要素に切り替え用のclassを付与
        for (i = 0; i < el.randomSwitching.length; ++i) {