cssAudio - ActiveCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmloctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <html lang="ja">
<head>
<meta charset="UTF-8">
<title>dropDownMenu</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="http://netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/styles/tomorrow-night-eighties.min.css"/>
<link rel="stylesheet" href="css/style.css">
</head>
<body>

<header class="l-header">
  <div class="l-container">
    <nav class="l-navigation">
    <ul id="dropDownMenu" class="dropDownMenu">
        <li><a href="#">mainMenu 1</a>
            <ul>
                <li><a href="#">subMenu 1-1</a></li>
                <li><a href="#">subMenu 1-2</a></li>
                <li><a href="#">subMenu 1-3</a></li>
              </ul>
          </li>
          <li><a href="#">mainMenu 2</a>
             <ul>
                  <li><a href="#">subMenu 2-1</a></li>
                 <li><a href="#">subMenu 2-2</a></li>
                  <li><a href="#">subMenu 2-3</a></li>
              </ul>
         </li>
         <li><a href="#">mainMenu 3</a></li>
      </ul>
    </nav>
  </div>
</header>


<div class="l-section l-container">
  <h2>jQuery</h2>
  <pre><code>$('body').prepend('&lt;div id=&quot;grayLayer&quot; class=&quot;grayLayer&quot;&gt;&lt;/div&gt;');
$("#dropDownMenu").before('&lt;i id=&quot;iconBars&quot; class=&quot;iconBars&quot;&gt;&lt;/i&gt;')
.before('&lt;i id=&quot;iconClose&quot; class=&quot;iconClose&quot;&gt;&lt;/i&gt;');
$("#iconBars").click(function(){
  $("#dropDownMenu li").show(200);
  $("#grayLayer").show(400);
  $("#iconBars").hide();
  $("#iconClose").show();
});
$("#iconClose").click(function(){
  $("#dropDownMenu li").hide(400);
  $("#grayLayer").hide(400);
  $("#iconClose").hide();
  $("#iconBars").show();
});</code></pre>

  <h2>HTML</h2>
  <pre><code>&lt;header class=&quot;l-header&quot;&gt;
  &lt;div class=&quot;l-container&quot;&gt;
    &lt;nav class=&quot;l-navigation&quot;&gt;
    &lt;ul id=&quot;dropDownMenu&quot; class=&quot;dropDownMenu&quot;&gt;
        &lt;li&gt;&lt;a href=&quot;#&quot;&gt;mainMenu 1&lt;/a&gt;
            &lt;ul&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;subMenu 1-1&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;subMenu 1-2&lt;/a&gt;&lt;/li&gt;
                &lt;li&gt;&lt;a href=&quot;#&quot;&gt;subMenu 1-3&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#&quot;&gt;mainMenu 2&lt;/a&gt;
             &lt;ul&gt;
                  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;subMenu 2-1&lt;/a&gt;&lt;/li&gt;
                 &lt;li&gt;&lt;a href=&quot;#&quot;&gt;subMenu 2-2&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href=&quot;#&quot;&gt;subMenu 2-3&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
         &lt;/li&gt;
         &lt;li&gt;&lt;a href=&quot;#&quot;&gt;mainMenu 3&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/nav&gt;
  &lt;/div&gt;
&lt;/header&gt;</code></pre>

  <h2>CSS</h2>
  <pre><code>html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

.grayLayer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
}

.l-header {
  margin: 0 0 1em;
  height: 44px;
}
.l-header:after {
  content: "";
  display: block;
  clear: both;
}

.iconBars {
  display: block;
  position: fixed;
  top: 15px;
  right: 15px;
  height: 44px;
  cursor: pointer;
}
.iconBars:before {
  font-family: 'FontAwesome';
  content: "\f0c9";
  display: inline-block;
  padding: 7px 9px;
  color: #333;
  background-color: #fefefe;
  font-size: 30px;
  line-height: 1;
  font-style: normal;
}

.iconClose {
  display: none;
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 1000;
  padding: 23px;
  cursor: pointer;
}
.iconClose:before, .iconClose:after {
  content: "";
  position: absolute;
  top: 50%;
  background-color: #fff;
  transform: rotate(45deg);
}
.iconClose:before {
  width: 2px;
  height: 30px;
  margin-top: -14px;
}
.iconClose:after {
  width: 30px;
  height: 2px;
  margin-left: -14px;
}

.dropDownMenu {
  position: fixed;
  top: 80px;
  right: 0;
  left: 0;
  z-index: 1000;
  margin: 0 auto;
  padding-left: 0;
  font-size: 1.2em;
  list-style-type: none;
}
.dropDownMenu li {
  display: none;
  position: relative;
  text-align: center;
}
.dropDownMenu li a {
  display: block;
  height: 44px;
  line-height: 44px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
}
.dropDownMenu li a:hover {
  color: lightcoral;
}
.dropDownMenu li:hover ul li {
  overflow: visible;
  height: 44px;
}

.dropDownMenu li ul {
  padding-left: 0;
  font-size: .8em;
  list-style: none;
}
.dropDownMenu li ul li {
  width: 100%;
}

@media screen and (min-width: 768px) {
  .l-navigation {
    float: right;
  }

  .grayLayer,
  .iconBars,
  .iconClose{
    display: none !important;
  }

  .dropDownMenu {
    display: block;
    position: initial;
    height: 44px;
    font-size: 1em;
  }
  .dropDownMenu li {
    float: left;
    display: block !important;
  }
  .dropDownMenu li a {
    padding: 0 2em;
    color: initial;
    background-color: #fff;
  }
  .dropDownMenu li a:hover {
    color: initial;
  }

  .dropDownMenu li ul {
    position: absolute;
    top: 100%;
    left: 0;
  }
  .dropDownMenu li ul li {
    overflow: hidden;
    height: 0;
    transition: .4s;
  }
  .dropDownMenu li ul li a {
    color: #fff;
    background-color: #333;
    border-top: 1px solid #888;
  }
  .dropDownMenu li ul li a:hover {
    color: #fff;
    background-color: #666;
  }
}</code></pre>


</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.4/highlight.min.js"></script>
<script src="js/script.js"></script>

</body>
</html>
            
          
!
            
              html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}
.grayLayer {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
}
.l-header {
  margin: 0 0 1em;
  height: 44px;
}
.l-header:after {
  content: "";
  display: block;
  clear: both;
}
.iconBars {
  display: block;
  position: fixed;
  top: 15px;
  right: 15px;
  height: 44px;
  cursor: pointer;
}
.iconBars:before {
  font-family: 'FontAwesome';
  content: "\f0c9";
  display: inline-block;
  padding: 7px 9px;
  color: #333;
  background-color: #fefefe;
  font-size: 30px;
  line-height: 1;
  font-style: normal;
}
.iconClose {
  display: none;
  position: fixed;
  top: 15px;
  right: 15px;
  z-index: 1000;
  padding: 23px;
  cursor: pointer;
}
.iconClose:before, .iconClose:after {
  content: "";
  position: absolute;
  top: 50%;
  background-color: #fff;
  transform: rotate(45deg);
  -webkit-transform: rotate(45deg);
}
.iconClose:before {
  width: 2px;
  height: 30px;
  margin-top: -14px;
}
.iconClose:after {
  width: 30px;
  height: 2px;
  margin-left: -14px;
}
.dropDownMenu {
  position: fixed;
  top: 80px;
  right: 0;
  left: 0;
  z-index: 1000;
  margin: 0 auto;
  padding-left: 0;
  font-size: 1.2em;
  list-style-type: none;
}
.dropDownMenu li {
  display: none;
  position: relative;
  text-align: center;
}
.dropDownMenu li a {
  display: block;
  height: 44px;
  line-height: 44px;
  font-weight: 600;
  color: #fff;
  text-decoration: none;
}
.dropDownMenu li a:hover {
  color: lightcoral;
}
.dropDownMenu li:hover ul li {
  overflow: visible;
  height: 44px;
}
.dropDownMenu li ul {
  padding-left: 0;
  font-size: .8em;
  list-style: none;
}
.dropDownMenu li ul li {
  width: 100%;
}

@media screen and (min-width: 768px) {
  .l-navigation {
    float: right;
  }
  .grayLayer,
  .iconBars,
  .iconClose{
    display: none !important;
  }
  .dropDownMenu {
    display: block;
    position: initial;
    height: 44px;
    font-size: 1em;
  }
  .dropDownMenu li {
    float: left;
    display: block !important;
  }
  .dropDownMenu li a {
    padding: 0 2em;
    color: initial;
    background-color: #fff;
  }
  .dropDownMenu li a:hover {
    color: initial;
  }
  .dropDownMenu li ul {
    position: absolute;
    top: 100%;
    left: 0;
  }
  .dropDownMenu li ul li {
    overflow: hidden;
    height: 0;
    transition: .4s;
  }
  .dropDownMenu li ul li a {
    color: #fff;
    background-color: #333;
    border-top: 1px solid #888;
  }
  .dropDownMenu li ul li a:hover {
    color: #fff;
    background-color: #666;
  }
}
.l-container {
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
  padding: 0 15px;
}
body {
  font-size: 14px;
  font-family: "Times New Roman", "游明朝", YuMincho, "Hiragino Mincho ProN", Meiryo, serif;
  color: #333;
}
            
          
!
            
              $('body').prepend('<div id="grayLayer" class="grayLayer"></div>');
$("#dropDownMenu").before('<i id="iconBars" class="iconBars"></i>')
.before('<i id="iconClose" class="iconClose"></i>');
$("#iconBars").click(function(){
  $("#dropDownMenu li").show(200);
  $("#grayLayer").show(400);
  $("#iconBars").hide();
  $("#iconClose").show();
});
$("#iconClose").click(function(){
  $("#dropDownMenu li").hide(400);
  $("#grayLayer").hide(400);
  $("#iconClose").hide();
  $("#iconBars").show();
});

// highlight.js
hljs.initHighlightingOnLoad()
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console