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.header
  .header-txt
    h1 TITLE 
      span > 
      span#title
main.main
  section.main-top 
    h2 このタイトルが
  section.main-middle 
    h2 セクションごとに
  section.main-bottom 
    h2 変わるやつです
              
            
!

CSS

              
                header
  height: 70px
  display: flex
  align-items: center
  background rgba(255,255,255,.45)
  padding 0 20px
  position fixed
  top 0
  left 0
  width 100%
  transition background .45s
  #title
    display inline-block
    background-color red
    color #fff
    padding: 3px

.main
  text-align center
  font-size 2rem
  section
     display: block
     height: 500px
     display: flex
     align-items: center
     justify-content: center
  &-top
    background #d0d0d0
  &-middle
    background #999
  &-bottom
    background #f5f5f5
              
            
!

JS

              
                (() => {
  const clientHeight = document.documentElement.clientHeight;
  const title = document.getElementById('title');
	const target = [...document.querySelectorAll('section')];
  const observer = new IntersectionObserver((changes) => {
    for (const change of changes) {
      const rect = change.target.getBoundingClientRect();
      const h = (0 < rect.top && rect.top < clientHeight) 
        || (0 < rect.bottom && rect.bottom < clientHeight)
        || (0 > rect.top && rect.bottom > clientHeight);
      if(h && change.isIntersecting) {
        title.textContent = change.target.querySelector('h2').textContent;
      }
    }
  });
  title.textContent = target[0].querySelector('h2').textContent;
  target.forEach(section => {
   observer.observe(section); 
  });
})();
              
            
!
999px

Console