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

              
                <div class="container">
    <header class="header">
        <div class="header__inner" id="headerInner">
            <a class="header__logo" href="">
                <img src="https://zenweb.info/wp-content/uploads/2023/05/hamburger-dummy-logo-blue.svg" alt="dummy logo">
            </a>
            <div class="header__menu">
                <ul class="menu__list">
                    <li class="menu__item">
                    <a class="menu__link" href="">会社概要</a>
                    </li>
                    <li class="menu__item">
                    <a class="menu__link" href="">お知らせ</a>
                    </li>
                    <li class="menu__item">
                    <a class="menu__link" href="">採用情報</a>
                    </li>
                </ul>
            </div>
            <div class="header__menu-btn" id="spMenuBtn">
                <span></span>
                <span></span>
                <span></span>
                <span>MENU</span>
            </div>
        </div>
    </header>
</div>
              
            
!

CSS

              
                /* すべての画面幅で適用されるCSS  */
.container {
    width: 100%;
}
.header {
    width: 100%;
    box-shadow: 0px 4px 4px -1px rgba(0,0,0,0.23);
}
.header__inner {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header__logo {
    display: block;
    font-size: 0;
}
.header__logo img {
    width: 100%;
    height: auto;
}

/* パソコンサイズ用のCSS  */
@media screen and (min-width:768px) {
    .header__inner {
        padding: 20px;
    }
    .header__logo {
        width: 160px;
        height: 19px;
        transition: opacity .2s ease;
    }
    .header__logo:hover {
        opacity: .7;
    }
    .menu__list {
        display: flex;
    }
    .menu__item:nth-child(n+2) {
        margin-left: 20px;
    }
    .menu__link {
        position: relative;
        display: block;
    }
    .menu__link::after {
        content: '';
        position: absolute;
        bottom: -5px;
        left: 0;
        width: 100%;
        height: 2px;
        background-color: #019ac6;
        transform: scaleX(0);
        transform-origin: left center;
        transition: transform .2s ease;
    }
    .menu__link:hover::after {
        transform: scaleX(1);
    }
    .header__menu-btn {
        display: none;
    }
}

/* スマートフォン、タブレットサイズ用のCSS */
@media screen and (max-width:767px) {
    .container {
        overflow: hidden;
    }
    .header {
        position: fixed;

        background: #fff;
    }
    .header__inner {
        position: relative;
        z-index: 10;
    }
    .header__logo {
        width: 125px;
        height: 15px;
        margin-left: 10px;
    }
    .header__menu {
        position: fixed;
        z-index: 5;
        top: 50px;
        width: 100%;
        height: calc(100vh - 50px);
        background: #fff;
        opacity: 0;
        visibility: hidden;
        transition: opacity .2s ease;
    }
    .header__inner.active .header__menu {
        opacity: 1;
        visibility: visible
    }
    .menu__list {
        border-top: 1px solid #d7d7d7;
    }
    .menu__item {
        border-bottom: 1px solid #d7d7d7;
    }
    .menu__link {
        display: block;
        padding: 13px 10px;
        color: #019ac6;
    }
    .header__menu-btn {
        position: relative;
        display: flex;
        justify-content: center;
        align-items: end;
        width: 50px;
        height: 50px;
        padding: 5px;
        cursor: pointer;
    }
    .header__menu-btn span:nth-child(-n+3) {
        position: absolute;
        display: block;
        width: 30px;
        height: 2px;
        background: #019ac6;
    }
    .header__menu-btn span:nth-child(1) {
        top: 10px;
        transition: all .2s ease;
    }
    .header__inner.active .header__menu-btn span:nth-child(1) {
        top: 20px;
        transform: rotate(45deg);
    }
    .header__menu-btn span:nth-child(2) {
        top: 18px;
        transition: opacity .2s ease;
    }
    .header__inner.active .header__menu-btn span:nth-child(2) {
        opacity: 0;
    }
    .header__menu-btn span:nth-child(3) {
        top: 26px;
        transition: all .2s ease;
    }
    .header__inner.active .header__menu-btn span:nth-child(3) {
        top: 20px;
        transform: rotate(-45deg);
    }
    .header__menu-btn span:nth-child(4) {
        font-size: 10px;
        color: #019ac6;
    }
}
              
            
!

JS

              
                // スマホ・タブレットサイズ時のみ表示されるメニューの開閉ボタンを変数に格納。
const spMenuBtn = document.getElementById("spMenuBtn");

// メニューや開閉ボタンをラップしている要素を変数に格納。
const headerInner = document.getElementById("headerInner");

// 開閉ボタンをクリックすると発火。
spMenuBtn.addEventListener("click", () => {
  // ラップ要素にactiveというクラスを付与する。
  headerInner.classList.toggle("active");
});
              
            
!
999px

Console