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 class="page-header">
  <nav>
    <a href="">
      <img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/162656/horizontal-logo-mobile.svg" alt="forecastr logo">
    </a>
    <ul class="main-menu">
      <li>
        <a href="">Work</a>
      </li>
      <li>
        <a href="">About</a>
      </li>
      <li>
        <a href="">Clients</a>
      </li>
      <li>
        <a href="">News</a>
      </li>
      <li>
        <a href="">Login</a>
      </li>
      <li>
        <a href="">Pricing</a>
      </li>
      <li class="btn-wrapper">
        <a href="" class="btn">Sign Up</a>
      </li>
    </ul>
    <ul class="secondary-menu">
      <li>
        <a href="">Login</a>
      </li>
      <li>
        <a href="">Pricing</a>
      </li>
      <li>
        <a href="" class="btn">Sign Up</a>
      </li>
    </ul>
    <button class="toggle-mobile-menu" aria-label="Open Mobile Menu" type="button">
      <svg width="40" height="40" viewBox="0 0 24 24" fill="none" class="open-menu" aria-hidden="true">
        <path d="M8 6.9834C7.44772 6.9834 7 7.43111 7 7.9834C7 8.53568 7.44772 8.9834 8 8.9834H16C16.5523 8.9834 17 8.53568 17 7.9834C17 7.43111 16.5523 6.9834 16 6.9834H8Z" fill="currentColor" />
        <path d="M7 12C7 11.4477 7.44772 11 8 11H16C16.5523 11 17 11.4477 17 12C17 12.5523 16.5523 13 16 13H8C7.44772 13 7 12.5523 7 12Z" fill="currentColor" />
        <path d="M8 15.017C7.44772 15.017 7 15.4647 7 16.017C7 16.5693 7.44772 17.017 8 17.017H16C16.5523 17.017 17 16.5693 17 16.017C17 15.4647 16.5523 15.017 16 15.017H8Z" fill="currentColor" />
        <path fill-rule="evenodd" clip-rule="evenodd" d="M22 12C22 17.5228 17.5228 22 12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12ZM20 12C20 16.4183 16.4183 20 12 20C7.58172 20 4 16.4183 4 12C4 7.58172 7.58172 4 12 4C16.4183 4 20 7.58172 20 12Z" fill="currentColor" />
      </svg>
      <svg width="40" height="40" viewBox="0 0 24 24" fill="none" class="close-menu" aria-hidden="true">
        <path d="M16.3394 9.32245C16.7434 8.94589 16.7657 8.31312 16.3891 7.90911C16.0126 7.50509 15.3798 7.48283 14.9758 7.85938L12.0497 10.5866L9.32245 7.66048C8.94589 7.25647 8.31312 7.23421 7.90911 7.61076C7.50509 7.98731 7.48283 8.62008 7.85938 9.0241L10.5866 11.9502L7.66048 14.6775C7.25647 15.054 7.23421 15.6868 7.61076 16.0908C7.98731 16.4948 8.62008 16.5171 9.0241 16.1405L11.9502 13.4133L14.6775 16.3394C15.054 16.7434 15.6868 16.7657 16.0908 16.3891C16.4948 16.0126 16.5171 15.3798 16.1405 14.9758L13.4133 12.0497L16.3394 9.32245Z" fill="currentColor" />
        <path fill-rule="evenodd" clip-rule="evenodd" d="M1 12C1 5.92487 5.92487 1 12 1C18.0751 1 23 5.92487 23 12C23 18.0751 18.0751 23 12 23C5.92487 23 1 18.0751 1 12ZM12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12C21 16.9706 16.9706 21 12 21Z" fill="currentColor" />
      </svg>
    </button>
  </nav>
</header>
<section class="hero">
  <div>
    <h1>Scroll Down ☟</h1>
    <span>To see the effect, check the demo on a large screen (>768px)</span>
  </div>
</section>
<section class="main-content">
  <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam vitae velit sed orci rhoncus aliquet. Etiam commodo sed lacus in mattis. Curabitur quis finibus diam, sit amet suscipit erat. Mauris augue lectus, faucibus non nibh non, laoreet iaculis sapien. Quisque at ligula et dolor hendrerit ullamcorper. Aenean ac ornare leo, id ornare est. Nam dignissim sapien lectus, quis finibus arcu sagittis eu. Nulla commodo commodo fringilla. Aliquam eu magna tincidunt, accumsan diam quis, vulputate nisi. Aliquam et libero at enim commodo facilisis non ac tellus. Etiam auctor pellentesque arcu ut semper. Donec justo ex, rutrum vel interdum vel, accumsan ut elit. Nunc et quam felis. Donec fringilla scelerisque orci ac tempus.</p>

  <p>Nullam eget auctor turpis. Proin quis lectus facilisis, elementum neque sed, tempus magna. Mauris accumsan erat felis, et efficitur elit convallis et. Praesent tristique, diam nec luctus fermentum, dui odio bibendum ipsum, eu tempor elit nunc eget tellus. Morbi nunc felis, ornare vel eros et, convallis dapibus felis. Maecenas libero dolor, tempus convallis ultricies ac, volutpat eget quam. Ut sollicitudin, nisi eu euismod tincidunt, nisi lorem egestas magna, a varius lectus diam vitae tellus. Fusce tincidunt tincidunt magna sed sodales. Vivamus scelerisque quam sed convallis ullamcorper. Duis felis metus, sodales sit amet odio sed, sagittis mollis turpis. Vivamus ut orci finibus, molestie libero id, egestas mauris.</p>

  <p>Aenean metus ante, viverra et cursus consequat, laoreet non mi. Ut tortor magna, scelerisque vitae efficitur at, varius lobortis arcu. Integer a imperdiet tortor, et porttitor massa. Cras eu felis pellentesque, sollicitudin massa at, interdum sem. Curabitur nec nibh maximus, maximus magna in, tempor arcu. Duis sed venenatis massa. Fusce dignissim porttitor dui, nec posuere diam mattis vitae. Maecenas et tincidunt massa. Sed nec velit fermentum, gravida leo ultrices, euismod felis. Donec blandit, eros non facilisis posuere, erat ipsum maximus nulla, a ornare nibh augue in mi.</p>

  <p>Morbi quis urna consectetur, mollis dolor ac, blandit diam. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas posuere tincidunt massa vel fermentum. Donec euismod tempor nunc eget luctus. Suspendisse potenti. Duis faucibus velit ante, semper auctor justo tristique non. Nulla at mi sagittis, varius felis eu, dignissim felis.</p>

  <p>Suspendisse potenti. Cras efficitur vel urna in bibendum. Nam imperdiet tortor ut mattis accumsan. Aliquam ornare urna a ante blandit consequat. Sed sit amet ipsum tortor. Maecenas consequat, sem at elementum dignissim, quam neque viverra magna, in aliquet massa mauris sed sapien. Cras vitae porta dui, mattis luctus eros. Vestibulum est quam, auctor non commodo non, lobortis sit amet erat. Curabitur luctus eros turpis, sit amet rhoncus neque posuere id.</p>
</section>
<footer class="page-footer">
  <small>Made with <span>❤</span> by <a href="https://georgemartsoukos.com/" target="_blank">George Martsoukos</a>
  </small>
</footer>
              
            
!

CSS

              
                /* RESET STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
:root {
  --white: white;
  --deeppurple: #7c2a8a;
  --red: #e31b23;
}

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

ul {
  list-style: none;
}

button {
  background: none;
  border: none;
  outline: none;
  cursor: pointer;
}

a {
  text-decoration: none;
  color: inherit;
}

::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.35);
}

::-webkit-scrollbar-thumb {
  background: var(--deeppurple);
}

body {
  font: 20px/1.5 "Inter", sans-serif;
}


/* HELPER CLASSES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.d-block {
  display: block !important;
}

.d-flex {
  display: flex !important;
}

.d-none {
  display: none !important;
}


/* HEADER STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  height: 100px;
}

.page-header nav {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  padding: 0 15px;
  background: var(--white);
  box-shadow: 0 1px 6px 0 rgba(0, 0, 0, 0.15);
}

.page-header ul {
  display: flex;
  align-items: center;
}

.page-header .main-menu {
  margin-left: 100px;
}

.page-header .main-menu li:nth-last-child(-n + 3) {
  display: none;
}

.page-header .secondary-menu {
  transform: translateX(200px);
  transition: transform 0.3s ease-out;
}

.page-header .secondary-menu.show-btn {
  transform: none;
}

.page-header li:not(:last-child) {
  margin-right: 50px;
}

.page-header .btn {
  display: inline-block;
  width: 150px;
  text-align: center;
  font-weight: 900;
  padding: 12px 6px;
  border-radius: 5px;
  color: var(--white);
  background: var(--deeppurple);
}

.page-header a {
  font-size: 18px;
  color: var(--deeppurple);
}

.page-header .toggle-mobile-menu {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.page-header .toggle-mobile-menu .close-menu {
  display: none;
}

.page-header .toggle-mobile-menu path {
  fill: var(--deeppurple);
}


/* SECTION #1 STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.hero {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: 100px;
  height: calc(100vh - 100px);
  background: #c4c4c4;
}

.hero h1 {
  font-size: 2.5rem;
}


/* SECTION #2 STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.main-content {
  max-width: 700px;
  padding: 0 15px;
  margin: 50px auto;
}

.main-content p + p {
  margin-top: 50px;
}


/* MQ STYLES
–––––––––––––––––––––––––––––––––––––––––––––––––– */
@media screen and (max-width: 1100px) {
  .page-header img {
    max-width: 140px;
  }

  .page-header .main-menu {
    display: none;
    position: absolute;
    top: 100px;
    left: 0;
    right: 0;
    padding: 15px;
    margin-left: 0;
    text-align: center;
    z-index: 1;
    background: var(--white);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.15);
  }

  .page-header .main-menu li {
    flex: 1;
  }

  .page-header .secondary-menu {
    transform: translateX(170px);
  }
  .page-header li:not(:last-child) {
    margin-right: 20px;
  }

  .page-header .toggle-mobile-menu {
    display: block;
  }
}

@media screen and (max-width: 767px) {
  .page-header {
    height: 70px;
  }

  .page-header .main-menu {
    top: 70px;
    flex-direction: column;
    align-items: start;
  }

  .page-header .main-menu li {
    flex-grow: 0;
  }

  .page-header .main-menu li + li {
    margin-top: 15px;
  }

  .page-header .main-menu li:nth-last-child(-n + 3) {
    display: block;
  }

  .page-header .secondary-menu {
    display: none;
  }

  .page-header .toggle-mobile-menu {
    position: static;
    transform: none;
  }

  .page-header .btn-wrapper {
    position: absolute;
    top: 0;
    right: 15px;
  }

  .page-header .btn {
    width: 120px;
    padding: 8px 16px;
  }

  .hero {
    margin-top: 70px;
    height: calc(100vh - 70px);
  }
}


/* FOOTER
–––––––––––––––––––––––––––––––––––––––––––––––––– */
.page-footer {
  font-size: 16px;
  text-align: center;
  padding: 20px;
  border-top: 1px solid #f2f2f2;
}

.page-footer span {
  color: var(--red);
}

              
            
!

JS

              
                const pageHeader = document.querySelector(".page-header");
const animatedUl = pageHeader.querySelector(".secondary-menu");
const mainMenu = pageHeader.querySelector(".main-menu");
const openMenu = pageHeader.querySelector(".open-menu");
const closeMenu = pageHeader.querySelector(".close-menu");
const toggleMobileMenu = pageHeader.querySelector(".toggle-mobile-menu");
const dNone = "d-none";
const dBlock = "d-block";
const dFlex = "d-flex";
const showBtn = "show-btn";
let targetScroll = window.innerHeight - pageHeader.offsetHeight;

window.addEventListener("scroll", () => {
  const scrollY = this.pageYOffset;

  if (scrollY > targetScroll) {
    animatedUl.classList.add(showBtn);
  } else {
    animatedUl.classList.remove(showBtn);
  }
});

window.addEventListener("resize", () => {
  targetScroll = window.innerHeight - pageHeader.offsetHeight;
});

toggleMobileMenu.addEventListener("click", function () {
  mainMenu.classList.toggle(dFlex);
  if (!openMenu.classList.contains(dNone)) {
    this.setAttribute("aria-label", "Close Mobile Menu");
    openMenu.classList.remove(dBlock);
    openMenu.classList.add(dNone);
    closeMenu.classList.remove(dNone);
    closeMenu.classList.add(dBlock);
  } else {
    this.setAttribute("aria-label", "Open Mobile Menu");
    openMenu.classList.remove(dNone);
    openMenu.classList.add(dBlock);
    closeMenu.classList.remove(dBlock);
    closeMenu.classList.add(dNone);
  }
});

              
            
!
999px

Console