Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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

              
                <header>
  <h1>font resize </h1>
  <ul>
    <li><a href="#">S</a></li>
    <li><a href="#">M</a></li>
    <li><a href="#">L</a></li>
  </ul>
</header>

<main>
  <p>
    Non cillum veniam dolor esse nulla consectetur fugiat nisi sint ad sit esse commodo. Ipsum ad quis pariatur consectetur sint Lorem. Tempor dolor ut amet fugiat dolore ea dolore. Proident occaecat culpa dolore commodo tempor eu labore fugiat minim deserunt ex dolor. Eu irure enim aute elit do dolore amet. Commodo eu officia proident aliqua eiusmod ea culpa. Est ea laboris sint magna eu Lorem enim id officia aute.
  </p>
  
  <p>
    Non cillum veniam dolor esse nulla consectetur fugiat nisi sint ad sit esse commodo. Ipsum ad quis pariatur consectetur sint Lorem. Tempor dolor ut amet fugiat dolore ea dolore. Proident occaecat culpa dolore commodo tempor eu labore fugiat minim deserunt ex dolor. Eu irure enim aute elit do dolore amet. Commodo eu officia proident aliqua eiusmod ea culpa. Est ea laboris sint magna eu Lorem enim id officia aute.
  </p>
  
</main>
              
            
!

CSS

              
                header {
  display: flex;
  width: 324px;
  margin: 0 auto;
  justify-content: space-between;
  margin-bottom: 40px;
  border-bottom: solid 1px #000;
}
h1 {
  font-size: 18px;
  color: #005711;
}

ul {
  margin-top: 10px;
  list-style-type: none;
  display: flex;
  gap: 8px;
}

li a {
  text-decoration: none;
  border: solid 1px #000;
  padding: 4px;
  background-color: #003d0c;
  color: #fff;
  font-weight: bold;
    
}

main {
  width: 324px;
  margin: 0 auto;
}

.small {
  font-size: 12px;
}

.medium {
  font-size: 16px;
}

.large {
  font-size: 20px;
}
              
            
!

JS

              
                $(function () {
  // 1 ボタンをクリックしたときに~
  $("header a").click(function () {
    
    // 2 あらかじめbodyにクラスが付いていれば削除
    $("body").removeClass();

    // 3 選択した要素(a)のテキスト内容を取得
    var size = $(this).html();

    // 4 もし選択したのがSだったら bodyに small クラスを追加
    if (size == "S") {
      $("body").addClass("small");
      
      // 5 じゃなくてMだったら bodyに medium クラスを追加
    } else if (size == "M") {
      $("body").addClass("medium");
      
      // 6 それ以外だったら bodyに large クラスを追加
    } else {
      $("body").addClass("large");
    }

    return false;
  });
});

              
            
!
999px

Console