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

              
                <!DOCTYPE html>
<html lang="ja">
<head>
   <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width">
   <title>サブメニュー</title>

   <style>

body{
   margin:0; 
}

.main-menu{
   display: flex; 
   padding: 0;
   margin:0 ; 
}

ul.main-menu a {
   background-color: #87cefa; 
   color: white;  
   line-height: 40px; 
   text-decoration: none;  
   font-weight: bold;        
   display: block;          
}

.main-menu li{
   list-style-type: none;  
   width:100%; 
   text-align: center; 
}

.main-menu ul{
   display: none; 
   padding: 0; 
}

.main-menu li:hover ul{
   display: block;
}

.main-menu a:hover{
   opacity:0.8;
}



/*ハンバーガーメニュー*/

.menu-trigger,
.menu-trigger span {
   display: inline-block;
   transition: all .4s;
   box-sizing: border-box;
}

.menu-trigger {
   margin:9px;
   z-index: 10000;
   position: fixed;
   width: 50px;
   right: 0;
   height: 44px;
}

.menu-trigger span {
   position: absolute;
   left: 0;
   width: 100%;
   height: 4px;
   background-color:#008080;
   border-radius: 4px;
}

.menu-trigger span:nth-of-type(1) {
   top: 0;
}

.menu-trigger span:nth-of-type(2) {
   top: 20px;
}

.menu-trigger span:nth-of-type(3) {
   bottom: 0;
}

.menu-trigger.active span:nth-of-type(1) {
   -webkit-transform: translateY(20px) rotate(-315deg);
   transform: translateY(20px) rotate(-315deg);
}

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

.menu-trigger.active span:nth-of-type(3) {
   -webkit-transform: translateY(-20px) rotate(315deg);
   transform: translateY(-20px) rotate(315deg);
}

/*ハンバーガーメニュー終わり*/


.header-right-sp {
   display:none;
}
/*👆ハンバーガーメニューを最初は表示させない*/

.ham-dis {
   display: none;
   transform: translateY(10px);
   text-align: center;
   position: fixed;
   background-color: white;
   height: 100%;
   width: 100%;
   top: -10px;
   z-index: 9999;
}

.ham-dis ul {
   padding: 0;
   position: relative;
   top: 4rem;
}

.ham-dis li {
   list-style-type: none;
   border-top: 1px dashed;
   border-bottom: 1px dashed;
   padding: 1rem 0;
}

.ham-dis a{
   text-decoration: none;
   color: black;
}

/*👆ハンバーガーメニュー内のテキストなどを装飾*/

.backshow{
   background-color: #87cefa;
   display: block;
}

/*👆ハンバーガーメニューをクリックしたときにメニューを1回表示させる指定*/


/*👇960px以下にした時にメニューバーを消し、ハンバーガーメニューを表示させる*/

@media screen and (max-width:960px){

   .main-menu-none{
      display: none;
   }

   .ham-dis .main-menu{
      display: block;
   }

   .ham-dis li {
    list-style-type: none;
    border:0;
        padding:0;
}

.ham-dis ul{
   position: initial;
}

   .header-right-sp{
      display: block;
   }

}


   </style>

</head>

<body>

      <div class="ham-dis">
         <ul class="main-menu">
   <li><a href="#">ホーム</a></li>
   <li><a href="#" class="spread-shrink1">お知らせ+</a>
      <ul class="fold-1">
         <li><a href="#">新サービスについて</a></li>
         <li><a href="#">弊社の活動</a></li>
      </ul>
   </li>
   <li><a href="#" class="spread-shrink2">お問い合わせ+</a>
      <ul class="fold-2">
         <li><a href="#">よくあるご質問</a></li>
         <li><a href="#">お問い合わせ先</a></li>
      </ul>
   </li>
      <li><a href="#">アクセス</a>
   </li>
</ul>
      </div>

                     <div class="header-right-sp">
            
                  <a class="menu-trigger" href="#">
                     <span></span>
                     <span></span>
                     <span></span>
                  </a>
            </div>



<ul class="main-menu main-menu-none">
   <li><a href="#">ホーム</a></li>
   <li><a href="#">お知らせ</a>
      <ul>
         <li><a href="#">新サービスについて</a></li>
         <li><a href="#">弊社の活動</a></li>
      </ul>
   </li>
   <li><a href="#">お問い合わせ</a>
      <ul>
         <li><a href="#">よくあるご質問</a></li>
         <li><a href="#">お問い合わせ先</a></li>
      </ul>
   </li>
      <li><a href="#">アクセス</a>
   </li>
</ul>

               <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
               <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>   


         <script>

                         $(".spread-shrink1").on('click', function(event) {
                           $(".spread-shrink1").toggleClass("plus-minus");

                           if($(".spread-shrink1").hasClass('plus-minus')){
                                $(".plus-minus").text("お知らせ-");
                                $("ul.fold-1").css("display","block");
                           }

                           else{
                           
                              $(".main-menu li:hover ul").css("display","none");
                              $("ul.fold-1").css("display","none");
                     

                               $(".spread-shrink1").text("お知らせ+");
                           }
   
});   

                         $(".spread-shrink2").on('click', function(event) {
                           $(".spread-shrink2").toggleClass("plus-minus");

                           if($(".spread-shrink2").hasClass('plus-minus')){
                                $(".plus-minus").text("お知らせ-");
                                $("ul.fold-2").css("display","block");
                           }

                           else{
                           
                              $(".main-menu li:hover ul").css("display","none");
                              $("ul.fold-2").css("display","none");
                     

                               $(".spread-shrink2").text("お知らせ+");
                           }
   
});   



            $(".menu-trigger").on('click', function(event) {

   $(this).toggleClass("active");/*👈ハンバーガーメニューのアニメーションを実装させているactiveクラスを切り替え*/

   $(".ham-dis").toggleClass("backshow");/*👈ハンバーガーメニューをクリックしてON、OFFを切り替える*/
   
});


         </script>     


</body>
</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console