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

              
                <div class="wrapper">
<header>
  <nav class="nav">
    <ul class="tooltip">
      
      <!--Main Category-->
      <li class="mainlink"><span><a href="#">About</a></span>
        <ul>
          <li><span><a href="#">Locations</a></span>
            <ul>
              <li><a href="#">Madison</a></li>
              <li><a href="#">Winder</a></li>
         
            </ul>
          </li>
          <li><span><a href="#">History</a></span></li>
          <li><span><a href="#">Hours</a></span></li>
          
        </ul>
      </li>
      
      <!--Main Category-->
      <li class="mainlink"><span><a href="#">Eat</a></span>
        <ul>
          <li><span><a href="#">Breakfast</a></span></li>
          <li><span><a href="#">Lunch</a></span>
            <ul>
              <li><a href="#">Starters</a></li>
              <li><a href="#">Entrees</a></li>
            </ul>
          </li>
          <li><span><a href="#">Dinner</a></span>
            <ul>
              <li>Starters</li>
              <li>Entrees</li>
            </ul>
          </li>
        </ul>
      </li>
      
      <!--Main Category-->
      <li><span><a href="#">Drink</a></span>
        <ul>
          <li><span><a href="#">Wine </a></span>
            <ul>
              <li>White </li>
              <li>Red </li>
              <li>Sparkling </li>
            </ul>
          </li>
          <li><span><a href="#">Beer</a></span>
            <ul>
              <li>On Tap  </li>
              <li>Bottled  </li>
              <li>Seasonal Craft  </li>
            </ul>
          </li>
          <li><span><a href="#">Cocktails</a></span>
            <ul>
              <li>Vodka  </li>
              <li>Whiskey  </li>
              <li>Scotch  </li>
            </ul> 
          </li>
         <li><span><a href="#">Dessert Drinks </a></span></li>
        </ul>
      </li>
      
      <!--Main Category-->
      <li><span><a href="#">Catering</a></span></li>
      
      <!--Main Category-->
      <li><span><a href="#">Events</a></span>
        <ul>
          <li><span><a href="#">Calendar</a></span></li>
          <li><span><a href="#">Venue Rental</a></span></li>
        </ul> 
      </li>
    </ul>
</nav>
</header>
  <div class="info">
<h1>jQuery Tooltip Menu with Animated Submenu</h1>
  <p>This isn't groundbreaking or anything, but if I wanted some non-tooltip submenu action I would've had to dig around much more than I felt like doing. </p>
  <p>The pattern for adding more than 3 levels on the second submenu should be pretty simple; add 35px for every new .push- pseduo class. The typography needs to be made responsive, but all of that will be for another day.</p>
    <p>Leave me your thoughts and comments!</p>
</div>

</div>
              
            
!

CSS

              
                 body {
  background-color: #e4dfd4;
  font-family: 'Source Sans Pro', sans-serif;
  color: #a93732;
  padding: 0;
  margin: 0;
  -webkit-backface-visibility: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.6em;
  overflow-x: hidden;
  -webkit-box-sizing: border-box; 
	-moz-box-sizing: border-box;    
	box-sizing: border-box;        
}

html {
font-size: 1.2em;
line-height: 0.3em;
margin: 0;
padding: 0;
}

a {
text-decoration: none;
color: #fefefe;
}

h1 {
 margin-top: 0;
 padding: 0;
 margin-bottom: 0.24em;
 font-size: 2em;
 line-height: 1.08em;
 font-family: 'Lato', sans-serif;
 }
 
/**demo style**/
.wrapper {
padding: 0;
margin: 0 auto;
width: 80%;
text-align: center;
margin-top: 0;
float: left;
display: block;
}

.info {
position: absolute;
margin-top: 20%;
margin-left: 10%;
width: 60%;
text-align: left;
}

header {
background: #555;
position: absolute;
display: block;
margin: 0;
width: 100%;
padding-top: 1.5em;
height: 70px;
}

.nav {
width: auto; /**menu items will adjust to any percentage value**/
height: 70px;
margin: 0;
margin-left: -1em; /**optional demo display**/
padding: 0;
display: block;
}

.nav li {
display: inline;
padding: 0;
float: left;
width: 15%;
height: auto;
margin: 0;
border-right: 1px solid rgba(250,250,250,.4);
background: rgb(101,170,173);
}

.nav li:last-child {
border-right: 0;
}

/**dropdown items**/
.tooltip span {
width: 100%;
height: 35px;
display: block;
padding-top: .4em;
padding-bottom: .4em;
color: #fefefe;
cursor: default;
}

/**arrow icon transform**/
.flip {
transform:rotateX(180deg);
-ms-transform:rotateX(180deg);
-webkit-transform:rotateX(180deg);
}

      
.level-2:before {
content: '';
width: 0; 
height: 0; 
display: inline-block;
border-left: 21px solid transparent;
border-right: 21px solid transparent;
border-bottom: 21px solid #fefefe;
position: absolute;
left: 50px;
top: -15px;
}

.level-2 {
background-color: #fefefe;
display: block;
position: absolute;
width: auto;
height: auto;
padding: 0;
display: none;
float: left;
list-style-type: none;
margin-top: 10px;
margin-left: 0px;
z-index: 9999;
}

ul.level-2{
padding: .5em 0 .3em 0;
vertical-align: middle;
}

.level-2 li {
border-right: 0;
margin: 0;
height: 35px;
display: block;
float: none;
background: none;
color: #65aaad;
text-align: left;
text-indent: 10px;
cursor: pointer;
vertical-align: middle;
padding: 0;
}

.level-2 li a {
color: #65aaad;
}


.level-2 li span {
width: 100%;
height: 35px;
display: block;
margin: 0;
cursor: pointer;
padding: 0;
}

.level-2 li i {
margin-left: 0px;
float: right;
margin-right: 11%;
margin-top: 2px;
color: #a93732;
font-size: 1.4em;
cursor: pointer;
pointer-events: none;
}


/**one child**/
li.push-one {
margin-bottom: 0;
margin-top: 35px;
}
      
/**two children**/
li.push-two{
margin-bottom: 0;
margin-top: 65px;
}

/**three children**/
li.push-three{
margin-bottom: 0;
margin-top: 100px;
}

/**third submenu**/
ul.level-3 {
display: none;
padding: 0;
margin: 0;
margin-left: 0px;
position: absolute;
float: left;
border: 0;
}


.level-3 li{
padding: 0;
height: auto;
margin: 0;
width: 201px;
text-indent: 10px;
background: #a93732;
color: #ecf0f1;
border-bottom: 1px solid #ccc;
border-right: 0;
vertical-align: middle;

}

.level-3 li span {
cursor: pointer;
padding: 0;
margin: 0;
border-right: 0;
}

.level-3 li a {
 color: #ecf0f1;
}

.level-3 li:hover {
background: #ddc062;
color: white;
cursor: pointer;
}
      
    
/**no children**/

li.solo span:hover a{
color: #ddc062;
}


              
            
!

JS

              
                $(document).ready(function(){
  

$('.tooltip li').find('ul').addClass('level-2');    $('.level-2 li').find('ul').removeClass('level-2').addClass('level-3'); 
 $('.level-2 li').width('200px');

     
 $('.tooltip li span').hover( function(){
     $(this).next('.level-2').show();  
},
    function(){
    $(this).next('.level-2').fadeOut("fast");  
 });
  $('.level-2').mouseenter(function() {
  $(this).stop().css('opacity', '1');  
});


$('.level-2').mouseleave(function() {
    $(this).hide(); 
$(this).find('.level-3').slideUp(); 
$('li').removeClass('push-two push-one push-three');

$(this).find('.fa-caret-down').removeClass('flip'); 
$(this).find('.fa-caret-down').hide();

   });
   
 $('.level-2 li').each(function(){
        if ($(this).find('ul').length == 0)
        {
      $(this).addClass('solo');
        }
        if ($(this).find('ul').length != 0)
        {
$(this).prepend('<i class="fa fa-caret-down"></i>');
        }
 $(this).find('i').hide();  
});
    

  
$('.level-2 li span').hover( function(){
     
       $(this).parent().find('.fa-caret-down').toggle();  
  if ($(this).parent().find('.level-3').is(':visible')) {
   
$(this).parent().find('.fa-caret-down').show();
}
});

$('.level-2 li span').click(function(){
$(this).parent().find('.fa-caret-down').toggleClass('flip'); 

  $(this).next('.level-3').slideToggle("fast");

if ($(this).next('ul').find('li').length == 1 ) {
$(this).parent().next().toggleClass('push-one');
}

if ($(this).next('ul').find('li').length == 2 ) {
$(this).parent().next().toggleClass('push-two');
}

if ($(this).next('ul').find('li').length == 3 ) {
$(this).parent().next().toggleClass('push-three');
}

 });
 
 });
              
            
!
999px

Console