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

              
                <header id="header">
  <div class="inner">
    <p class="logo">COMPANY</p>
    <ul class="navi">
      <li><a href="#">選ばれる理由</a></li>
      <li><a href="#">サービス</a></li>
      <li><a href="#">制作事例</a></li>
    </ul>
  </div>
</header>
<div id="main"></div>
              
            
!

CSS

              
                header {
  z-index: 999;
  top: 0;
  left: 0;
  width: 100%;
  padding: 20px 40px;
  box-sizing: border-box;
}
header .inner {
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}
.logo {
  position: relative;
  margin: 0;
  padding: 0;
  font-weight: bold;
}

/* header-navi */

header .navi {
  margin: 0 0 0 auto;
  padding: 0;
  font-size: 14px;
  font-weight: bold;
  display: flex;
  list-style: none;
}
header .navi li {
  margin: 5px 0 5px 40px;
}
header .navi li:first-child {
  margin-left: 0;
}
header .navi li a {
  display: block;
  box-sizing: border-box;
  text-decoration: none;
  color: #333;
}
header .navi li a:hover {
  text-decoration: underline;
}

/* add css  */

#header.scroll {
  position: fixed;
  background: #EEE;
  animation-name: anime;
  animation-duration: 0.3s;
}
@keyframes anime {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

/* layout */

body{
  margin: 0;
  padding: 0;
}
#main{
  height: 3000px;
}
              
            
!

JS

              
                $(function () {
  var $header = $("#header");
  var scrollSize = 800; //超えると表示
  $(window).on("load scroll", function () {
    var value = $(this).scrollTop();
    if (value > scrollSize) {
      $header.addClass("scroll");
    } else {
      $header.removeClass("scroll");
    }
  });
});

              
            
!
999px

Console