Pen Settings

HTML

CSS

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

JavaScript

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

Packages

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.

Behavior

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.

HTML

              
                <body data-tag="body" data-bs-theme="light" style="width: 500px; margin: 0 auto">

  <div class="form-check form-switch form-check-reverse display-6">
    <input class="form-check-input" type="checkbox" role="switch" id="darkModeSwitch">
    <label class="form-check-label" for="darkModeSwitch">Тёмная тема</label>
  </div>

  <div class="container">
    <div class="border row lh-1 mt-5 p-5 rounded-5">
      <div class="align-items-center col d-flex flex-wrap mb-3">
        <h1 class="fs-6 lh-1 m-0 text-uppercase">Посадочный талон</h1>
        <span class="fs-6 fw-light ms-2 text-dark-emphasis text-uppercase">Boarding
          Pass</span>
      </div>
      <div class="border border-2 border-warning col-12 mb-5 px-5 py-3 rounded-4">
        <div class="gap-4 row row-cols-1">
          <div class="align-items-center col d-flex flex-wrap">
            <h2 class="fs-6 lh-1 m-0 text-uppercase">Рейс</h2>
            <span class="fs-6 fw-light ms-2 text-dark-emphasis text-uppercase">Flight</span>
            <p class="fs-2 fw-bold mb-0 mt-2 w-100">SU 2101</p>
          </div>
          <div class="align-items-center col d-flex flex-wrap">
            <h2 class="fs-6 lh-1 m-0 text-uppercase">Посадка</h2>
            <span class="fs-6 fw-light ms-2 text-dark-emphasis text-uppercase">Boarding</span>
            <p class="fs-2 fw-bold mb-0 mt-2 w-100">17:55–18:20</p>
          </div>
          <div class="align-items-center d-flex flex-wrap">
            <h2 class="fs-6 lh-1 m-0 text-uppercase">Выход</h2>
            <span class="fs-6 fw-light ms-2 text-dark-emphasis text-uppercase">Gate</span>
            <p class="fs-2 fw-bold mb-0 mt-2 text-primary w-100">C1</p>
          </div>
          <div class="align-items-center col d-flex flex-wrap">
            <h2 class="fs-6 lh-1 m-0 text-uppercase">Место</h2>
            <span class="fs-6 fw-light ms-2 text-dark-emphasis text-uppercase">Seat</span>
            <p class="fs-2 fw-bold mb-0 mt-2 text-primary w-100">F12</p>
          </div>
        </div>
      </div>

      <div class="col-12 d-flex">
        <div class="font-monospace me-5">
          <div class="d-flex flex-wrap text-info">
            <span class="w-100 fs-6 text-dark-emphasis text-uppercase">26.06.2020</span>
            <h2 class="m-0 text-uppercase">Moscow</h2>
            <span class="h2 mb-0 ms-2 text-dark-emphasis text-uppercase">SVO</span>
            <p class="fs-2 fw-bold mb-0 w-100">18:45</p>
          </div>
          <div class="display-1 text-dark-emphasis">↓</div>
          <div class="d-flex flex-wrap text-success">
            <span class="w-100 fs-6 text-dark-emphasis text-uppercase">27.06.2020</span>
            <h2 class="m-0 text-uppercase">Vladivostok</h2>
            <span class="h2 mb-0 ms-2 text-dark-emphasis text-uppercase">VVO</span>
            <p class="fs-2 fw-bold mb-0 w-100">01:20</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</body>
              
            
!

CSS

              
                [data-bs-theme=dark] {
  --bs-primary: #a8d8ea;
  --bs-secondary: #aa96da;
  --bs-success: #bbfcba;
  --bs-danger: #fcbad3;
  --bs-warning: #ffffd2;
  --bs-info: #96a9da;
  --bs-primary-rgb: 168, 216, 234;
  --bs-secondary-rgb: 170, 150, 218;
  --bs-success-rgb: 187, 252, 186;
  --bs-danger-rgb: 252, 186, 211;
  --bs-warning-rgb: 255, 255, 210;
  --bs-info-rgb: 150, 169, 218;
}
              
            
!

JS

              
                const darkModeSwitchInput = document.querySelector('input#darkModeSwitch');
const bodyTag = document.querySelector('[data-tag="body"]');

const themeSwitch = () => {
  const currentState = bodyTag.getAttribute('data-bs-theme');
  
  switch (currentState) {
    case "light":
      bodyTag.setAttribute('data-bs-theme', "dark");
      break;
    default:
      bodyTag.setAttribute('data-bs-theme', "light");
  }
};

darkModeSwitchInput.addEventListener('change', themeSwitch);
              
            
!
999px

Console