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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ 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>
    <img src="https://hajimete.org/wp-content/uploads/2019/06/title.png" alt="logo" />
  </header>
  <main>
    <div id="top_contents">
      <div class="top_inner">
        <h1>我々は宇宙人だ。</h1>
        <p>
          世界征服には、どうしたってUFOは欠かせない代物である。<br />
          我々のUFOを紹介しよう!
        </p>
        <a href="#ufo">UFOについて詳しく知る</a>
      </div>
    </div>
    <div id="himitukiti">
      <img src="https://upload.wikimedia.org/wikipedia/commons/d/df/PurportedUFO2.jpg" alt="秘密基地1" />
      <img src="https://upload.wikimedia.org/wikipedia/commons/d/df/PurportedUFO2.jpg" alt="秘密基地1" />
      <img src="https://upload.wikimedia.org/wikipedia/commons/d/df/PurportedUFO2.jpg" alt="秘密基地1" />
      <img src="https://upload.wikimedia.org/wikipedia/commons/d/df/PurportedUFO2.jpg" alt="秘密基地1" />
      <img src="https://upload.wikimedia.org/wikipedia/commons/d/df/PurportedUFO2.jpg" alt="秘密基地1" />
      <img src="https://upload.wikimedia.org/wikipedia/commons/d/df/PurportedUFO2.jpg" alt="秘密基地1" />
    </div>
    <div id="ufo">
      <div class="ufo_inner">
        <h2>UFOは超でっかい!(ヘッダーは↑ここで止まります)</h2>
        <p>何もしていない場合、あと<span class="text"></span>px下まで行ってこの文字は見えなくなってしまします。</p>
        <a href="https://ja.wikipedia.org/wiki/%E6%9C%AA%E7%A2%BA%E8%AA%8D%E9%A3%9B%E8%A1%8C%E7%89%A9%E4%BD%93">さらに詳しく見る-Wikipediaへ</a>
      </div>
      <div class="to_top"><a href="#top_contents">上へ戻る</a></div>
    </div>
  </main>
              
            
!

CSS

              
                body {
      margin: 0;
      padding: 0;
    }
    a {
      text-decoration: none;
      color: rgb(13, 199, 143);
      display: block;
    }
    header {
      position: fixed;
      z-index: 10;
      top:0;
      left:0;
      width: 100%;
      height: 60px;
      background: #fff;
      box-shadow: 0 2px 30px -20px rgba(0,0,0,.4);
    }
    header img {
      position: absolute;
      top: 50%;
      left: 20px;
      height: 45%;
      display:block;
      transform: translateY(-50%);
      -webkit-transform: translateY(-50%);
    }
    #top_contents, #ufo {
      position: relative;
      width: 100%;
      height: 800px;
      text-align: center;
      display: block;
    }
    #ufo {
      height: 1700px;
    }
    .top_inner {
      position: absolute;
      top: 50%;
      left: 50%;
      transform:translate(-50%, -50%);
      -webkit-transform:translate(-50%, -50%);
    }
    .ufo_inner {
      position: absolute;
      top: 0%;
      left: 50%;
      transform:translateX(-50%);
      -webkit-transform:translateX(-50%);
    }
    .ufo_inner h2 {
      margin: 0 auto 0;
      line-height: 1.1;
    }
    .top_inner a, .ufo_inner a {
      display: block;
      padding: 8px 20px;
      margin-top: 30px;
      border: 1px solid rgb(13, 199, 143);
      border-radius: 12px;
      min-width: 240px;
    }
    #himitukiti {
      letter-spacing: -.4em;
      line-height: 0;
      width: 100%;
    }
    #himitukiti img {
      display: inline-block;
      width: 50%;
    }
.to_top {
  position:absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 20px 0;
  text-align: center;
  background: rgb(13, 199, 143);
  font-weight: 400;
  font-size: 24px;
}
.to_top a {
  color: #fff;
}
              
            
!

JS

              
                $(function(){
  $('a[href^="#"]').on("click", function() {
    var speed = 600;
    var header_height = $("header").height();
    var href= $(this).attr("href");
    var target = $(href == "#" || href == "" ? 'html' : href);
    var position = target.offset().top - header_height;
    $('body,html').animate({scrollTop:position}, speed, 'swing');
    return false;
  });
});

$(function() {
  $(".text").text($("header").height());
});

              
            
!
999px

Console