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="openbtn4"><span></span><span></span><span></span></div>

<!--必須 jQueryではnavでは動作しなかったためクラス名をつけた-->
<nav class="navi">
  <ul>
    <li>Top</li>
    <li>Company</li>
    <li>Servise</li>
    <li>Cobtact</li>
  </ul>
</nav>


              
            
!

CSS

              
                /*==================================================
 nav
===================================*/
/*必須 jQueryではnavでは動作しなかったためクラス名をつけた*/
.navi{
  background:#0bd;
  /* position:absolute だと右側にブラウザを超えて余白ができてしまう*/
  position: fixed;
  z-index:9980;
  top:-120%;
  right: 0;
  height:100vh;
  width:100%;
  transition: .5s;
}

.navi.open{
   top:0;
}

/*-------その他---------*/

/*ulの余分な余白削除↓これはcodepenの余白*/
ul{
  padding-inline-start: 0px;
}

li{
  list-style:none;
  padding:15px;
  font-size:18px;
  border-bottom:1px dotted #000;
  box-sizing: border-box;
}

/*==================================================
ボタンのみ 
引用元:https://coco-factory.jp/ugokuweb/move01-cat/humbugermenu/
===================================*/

/*ボタン外側※レイアウトによってpositionや形状は適宜変更してください*/
.openbtn4{
  position: relative;/*ボタン内側の基点となるためrelativeを指定*/
  position: absolute;
  background:#D54884;
  cursor: pointer;
  width: 50px;
  height:50px;
  border-radius: 5px;
  right:5px;
  z-index:9999;
}

/*ボタン内側*/
.openbtn4 span{
    display: inline-block;
    transition: all .4s;/*アニメーションの設定*/
    position: absolute;
    left: 14px;
    height: 2px;
    border-radius: 5px;
  background: #fff;
    width: 45%;
  }


.openbtn4 span:nth-of-type(1) {
  top:13px; 
}

.openbtn4 span:nth-of-type(2) {
  top:19px;
}

.openbtn4 span:nth-of-type(3) {
  top:25px;
}

.openbtn4 span:nth-of-type(3)::after {
  content:"Menu";/*3つ目の要素のafterにMenu表示を指定*/
  position: absolute;
  top:5px;
  left:-2px;
  color: #fff;
  font-size: 0.6rem;
  text-transform: uppercase;
}

/*activeクラスが付与されると線が回転して×になり、Menu⇒Closeに変更*/

.openbtn4.active span:nth-of-type(1) {
    top: 14px;
    left: 18px;
    transform: translateY(6px) rotate(-45deg);
    width: 30%;
}

.openbtn4.active span:nth-of-type(2) {
  opacity: 0;
}

.openbtn4.active span:nth-of-type(3){
    top: 26px;
    left: 18px;
    transform: translateY(-6px) rotate(45deg);
    width: 30%;
}

.openbtn4.active span:nth-of-type(3)::after {
  content:"Close";/*3つ目の要素のafterにClose表示を指定*/
    transform: translateY(0) rotate(-45deg);
  top:5px;
  left:4px;
}

              
            
!

JS

              
                //jQueryで実装
$(".openbtn4").click(function () {
    $(this).toggleClass('active');
    $(".navi").toggleClass('open');
});

//javascriptで実装
//const btn = document.querySelector('.openbtn4');
//const nav = document.querySelector('.navi');
 
//btn.addEventListener('click' , () =>{
//btn.classList.toggle('active');
//nav.classList.toggle('open')
//});

              
            
!
999px

Console