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

              
                <body>
  <header>
    <h1>header</h1>   
    </header>
  
  <nav>
    <ul>
      <li><a href="#">menu1</a></li>
      <li><a href="#">menu2</a></li>
      <li><a href="#">menu3</a></li>
      <li><a href="#">menu4</a></li>
      </ul>
    </nav>
  
  <main>
    <p>
      Ut est esse adipisicing veniam dolor nulla duis sunt deserunt tempor qui. Minim pariatur culpa consequat ea elit dolor et cupidatat magna enim. Est cillum do consectetur adipisicing ut adipisicing pariatur cillum veniam incididunt ad ex laborum. Esse commodo reprehenderit minim dolore sit non tempor. Magna commodo nulla ullamco sunt dolore.
      </p>
    <p>
      Ut est esse adipisicing veniam dolor nulla duis sunt deserunt tempor qui. Minim pariatur culpa consequat ea elit dolor et cupidatat magna enim. Est cillum do consectetur adipisicing ut adipisicing pariatur cillum veniam incididunt ad ex laborum. Esse commodo reprehenderit minim dolore sit non tempor. Magna commodo nulla ullamco sunt dolore.
      </p>
    <p>
      Ut est esse adipisicing veniam dolor nulla duis sunt deserunt tempor qui. Minim pariatur culpa consequat ea elit dolor et cupidatat magna enim. Est cillum do consectetur adipisicing ut adipisicing pariatur cillum veniam incididunt ad ex laborum. Esse commodo reprehenderit minim dolore sit non tempor. Magna commodo nulla ullamco sunt dolore.
      </p>
    <p>
      Ut est esse adipisicing veniam dolor nulla duis sunt deserunt tempor qui. Minim pariatur culpa consequat ea elit dolor et cupidatat magna enim. Est cillum do consectetur adipisicing ut adipisicing pariatur cillum veniam incididunt ad ex laborum. Esse commodo reprehenderit minim dolore sit non tempor. Magna commodo nulla ullamco sunt dolore.
      </p>
    <p>
      Ut est esse adipisicing veniam dolor nulla duis sunt deserunt tempor qui. Minim pariatur culpa consequat ea elit dolor et cupidatat magna enim. Est cillum do consectetur adipisicing ut adipisicing pariatur cillum veniam incididunt ad ex laborum. Esse commodo reprehenderit minim dolore sit non tempor. Magna commodo nulla ullamco sunt dolore.
      </p>
    </main>
  </body>
              
            
!

CSS

              
                body {
  width: 324px;
  margin: 0 auto;
  background-color: #e6e6e6;
}

h1 {
  text-align: center;
  width: 100%;
  padding: 90px 0;
  background-color: #ada17f;
  
}

ul {
  width: 270px;
  display: flex;
  justify-content: flex-start;
  gap: 12px;
  padding-left: 0px;
  background-color: #f2e3bb;
}

li {
  list-style-type: none;
}

li a{
  text-decoration: none;
  color: #000;
}
              
            
!

JS

              
                $(function(){
  // 1 変数navGoに、navの上端からの距離の初期数値を代入
  var navGo = $("nav").offset().top;

  // 2 ブラウザをスクロールしたときに~
  $(window).scroll(function(){
    // 3 スクロール量とnav要素の初期位置navGoを比較
    if($(window).scrollTop() > navGo){
      // 4 条件を満たした場合:nav要素をブラウザ上部に固定
      $("nav").css("position", "fixed");
      $("nav").css("top", "0px");
    }else{
      // 5 満たさない場合:nav要素を通常の配置にする
      $("nav").css("position", "static");
    }
  });
});
              
            
!
999px

Console