我想为菜单栏

时间:2015-08-04 10:42:49

标签: dynamic drop-down-menu width

如果您访问htp://www.hmhao.blogspot.in,您会看到我添加了一个菜单栏,我想要的是为不同的dopdown菜单设置不同的宽度。例如。我的网站"电影系列"下拉菜单的宽度为182px,但我想设置我的" 0-9"的宽度。菜单为15 px因为它只包含数字,并且宽度为182px并不好看,试用了3天但无法找到解决方案。

找到下面的代码,我不知道哪个特定代码更改了宽度,所以添加了完整的CSS,只添加了所需的HTML,如果需要也添加了javascript。

请帮忙。岩石石



   

(function($) {

  $.fn.menumaker = function(options) {
      
      var cssmenu = $(this), settings = $.extend({
        title: "Menu",
        format: "dropdown",
        sticky: false
      }, options);

      return this.each(function() {
        cssmenu.prepend('<div id="menu-button">' + settings.title + '</div>');
        $(this).find("#menu-button").on('click', function(){
          $(this).toggleClass('menu-opened');
          var mainmenu = $(this).next('ul');
          if (mainmenu.hasClass('open')) { 
            mainmenu.hide().removeClass('open');
          }
          else {
            mainmenu.show().addClass('open');
            if (settings.format === "dropdown") {
              mainmenu.find('ul').show();
            }
          }
        });

        cssmenu.find('li ul').parent().addClass('has-sub');

        multiTg = function() {
          cssmenu.find(".has-sub").prepend('<span class="submenu-button"></span>');
          cssmenu.find('.submenu-button').on('click', function() {
            $(this).toggleClass('submenu-opened');
            if ($(this).siblings('ul').hasClass('open')) {
              $(this).siblings('ul').removeClass('open').hide();
            }
            else {
              $(this).siblings('ul').addClass('open').show();
            }
          });
        };

        if (settings.format === 'multitoggle') multiTg();
        else cssmenu.addClass('dropdown');

        if (settings.sticky === true) cssmenu.css('position', 'fixed');

        resizeFix = function() {
          if ($( window ).width() > 768) {
            cssmenu.find('ul').show();
          }

          if ($(window).width() <= 768) {
            cssmenu.find('ul').hide().removeClass('open');
          }
        };
        resizeFix();
        return $(window).on('resize', resizeFix);

      });
  };
})(jQuery);

(function($){
$(document).ready(function(){

$("#cssmenu").menumaker({
   title: "Menu",
   format: "multitoggle"
});


});
})(jQuery);
&#13;
@import url(http://fonts.googleapis.com/css?family=Open+Sans:400,700);
#cssmenu,
#cssmenu ul,
#cssmenu ul li,
#cssmenu ul li a,
#cssmenu #menu-button {
  margin: 0;
  padding: 0;
  border: 0;
  list-style: none;
  line-height: 1;
  display: block;
  position: relative;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
#cssmenu:after,
#cssmenu > ul:after {
  content: ".";
  display: block;
  clear: both;
  visibility:hidden;;  line-height: 0;
  height: 0;
}
#cssmenu #menu-button {
  display: none;
}
#cssmenu {
  width: auto;
  border-radius: 5px;
  font-family: 'Open Sans', Helvetica, sans-serif;
  background: 3DB2E1;
  background: -o-linear-gradient(top, #69c4e8, #21a1d4);
  background: -ms-linear-gradient(top, #69c4e8, #21a1d4);
  background: -webkit-linear-gradient(top, #69c4e8, #21a1d4);
  background: -moz-linear-gradient(top, #69c4e8, #21a1d4);
  background: linear-gradient(to bottom, #69c4e8, #21a1d4);
  box-shadow: inset 0 -3px 0 #1f97c7, inset 0 -3px 3px #1f9acc, inset 0 2px 2px #9ad7ef, inset 1px 0 2px #22a4d9, inset -1px 0 2px #22a4d9, 0 1px 1px rgba(0, 0, 0, 0.1), 0 2px 2px rgba(0, 0, 0, 0.06), 0 3px 3px rgba(0, 0, 0, 0.17), 2px 1px 2px rgba(0, 0, 0, 0.05), -2px 1px 2px rgba(0, 0, 0, 0.05);
}
#cssmenu.align-center > ul {
  font-size: 0;
  text-align: center;
}
#cssmenu.align-center ul ul {
  text-align: left;
}
#cssmenu.align-center > ul > li {
  display: inline-block;
  float: none;
}
#cssmenu.align-right > ul > li {
  float: right;
}
#cssmenu.align-right ul ul {
  text-align: right;
}
#cssmenu > ul > li {
  float: left;
}
#cssmenu > ul > li > a {
  padding: 10px 6px;
  font-size: 12px;
  color: #ffffff;
  text-transform: uppercase;
  letter-spacing: 0px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  font-weight: 700;
  text-decoration: none;
  -webkit-transition: color .2s ease;
  -moz-transition: color .2s ease;
  -ms-transition: color .2s ease;
  -o-transition: color .2s ease;
  transition: color .2s ease;
}
#cssmenu > ul > li:hover > a,
#cssmenu > ul > li > a:hover,
#cssmenu > ul > li.active > a {
  color: #cae5fd;
}
#cssmenu > ul > li.has-sub > a {
  padding-right: 25px;
}
#cssmenu ul > li.has-sub > a:after {
  content: '';
  position: absolute;
  right: 5px;
  top: 7.5px;
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #3db2e1;
  background: -webkit-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: -ms-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: -moz-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: -o-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: linear-gradient(to bottom, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  box-shadow: inset 0 -1px 1px #209ed0, inset 0 2px 1px #7fcceb;
  background-size: 36px 36px;
  background-position: 0 0;
  background-repeat: no-repeat;
  -webkit-transition: all 0.1s ease-out;
  -moz-transition: all 0.1s ease-out;
  -ms-transition: all 0.1s ease-out;
  -o-transition: all 0.1s ease-out;
  transition: all 0.1s ease-out;
}
#cssmenu ul > li.has-sub:hover > a:after {
  background-position: 0 -18px;
}
#cssmenu ul > li.has-sub > a:before {
  content: '';
  position: absolute;
  right: 11px;
  top: 15.5px;
  display: block;
  width: 0;
  height: 0;
  border: 3px solid transparent;
  border-top-color: #ffffff;
  z-index: 99;
}
#cssmenu ul > li.has-sub:hover > a:before {
  border-top-color: #19799f;
}
#cssmenu ul ul {
  position: absolute;
  left: -9999px;
  opacity: 0;
  -webkit-transition: top .2s ease, opacity .2s ease;
  -moz-transition: top .2s ease, opacity .2s ease;
  -ms-transition: top .2s ease, opacity .2s ease;
  -o-transition: top .2s ease, opacity .2s ease;
  transition: top .2s ease, opacity .2s ease;
}
#cssmenu > ul > li > ul {
  top: 91px;
  padding-top: 8px;
  border-radius: 5px;
}
#cssmenu > ul > li:hover > ul {
  left: auto;
  top: 30px;
  opacity: 1;
}
#cssmenu.align-right > ul > li:hover > ul {
  right: 0;
}
#cssmenu ul ul ul {
  top: 40px;
}
#cssmenu ul ul > li:hover > ul {
  top: 0;
  left: 176px;
  padding-left: 10px;
  opacity: 1;
}
#cssmenu.align-right ul ul > li:hover > ul {
  left: auto;
  right: 178px;
  padding-left: 0;
  padding-right: 10px;
  opacity: 1;
}
#cssmenu ul ul li a {
  width: 182px;
  padding: 10px 10px;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
  color: #ffffff;
  text-decoration: none;
  background: #3db2e1;
  -webkit-transition: color .2s ease;
  -moz-transition: color .2s ease;
  -ms-transition: color .2s ease;
  -o-transition: color .2s ease;
  transition: color .2s ease;
}
#cssmenu ul ul li:hover > a,
#cssmenu ul ul li > a:hover,
#cssmenu ul ul li.active > a {
  color: #cae5fd;
}
#cssmenu ul ul li:first-child > a {
  border-top-left-radius: 5px;
  border-top-right-radius: 5px;
  box-shadow: inset 0 2px 2px #88d0ed;
}
#cssmenu ul ul li:last-child > a {
  border-bottom-left-radius: 5px;
  border-bottom-right-radius: 5px;
  box-shadow: inset 0 -3px 0 #27a9de, inset 0 -3px 3px #1f9acc, 0 1px 1px rgba(0, 0, 0, 0.03), 0 2px 2px rgba(0, 0, 0, 0.05), 0 2px 3px rgba(0, 0, 0, 0.13);
}
#cssmenu ul ul > li.has-sub > a:after {
  right: 12px;
  top: 7.5px;
  background: #3db2e1;
  background: -webkit-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: -ms-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: -moz-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: -o-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  background: linear-gradient(to bottom, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
  box-shadow: inset 0 -1px 1px #209ed0, inset 0 2px 1px #7fcceb;
  background-size: 36px 36px;
  background-position: 0 0;
  background-repeat: no-repeat;
}
#cssmenu.align-right ul ul > li.has-sub > a:after {
  right: auto;
  left: 12px;
}
#cssmenu ul ul > li.has-sub:hover > a:after {
  background-position: 0 -18px;
}
#cssmenu ul ul > li.has-sub > a:before {
  top: 13.5px;
  right: 16px;
  border-top-color: transparent;
  border-left-color: #ffffff;
}
#cssmenu.align-right ul ul > li.has-sub > a:before {
  top: 15.5px;
  right: auto;
  left: 16px;
  border-top-color: transparent;
  border-right-color: #ffffff;
  border-left-color: transparent;
}
#cssmenu ul ul > li.has-sub:hover > a:before {
  border-top-color: transparent;
  border-left-color: #1c89b5;
}
#cssmenu.align-right ul ul > li.has-sub:hover > a:before {
  border-top-color: transparent;
  border-left-color: transparent;
  border-right-color: #1c89b5;
}
@media all and (max-width: 768px), only screen and (-webkit-min-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (min--moz-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (-o-min-device-pixel-ratio: 2/1) and (max-width: 1024px), only screen and (min-device-pixel-ratio: 2) and (max-width: 1024px), only screen and (min-resolution: 192dpi) and (max-width: 1024px), only screen and (min-resolution: 2dppx) and (max-width: 1024px) {
  #cssmenu {
    width: 100%;
  }
  #cssmenu ul,
  #cssmenu ul ul,
  #cssmenu ul ul ul,
  #cssmenu > ul,
  #cssmenu.align-center > ul,
  #cssmenu > ul > li > ul,
  #cssmenu > ul > li:hover > ul,
  #cssmenu ul ul li:hover > ul,
  #cssmenu ul ul ul li:hover > ul,
  #cssmenu.align-right ul ul,
  #cssmenu.align-right ul ul li:hover > ul,
  #cssmenu.align-right ul ul ul li:hover > ul {
    position: relative;
    left: 0;
    right: auto;
    top: 0;
    width: 100%;
    display: none;
    padding: 0;
    opacity: 1;
    text-align: left;
  }
  #cssmenu ul li {
    width: 100%;
    border-top: 1px solid rgba(120, 120, 120, 0.2);
  }
  #cssmenu > ul > li > a,
  #cssmenu ul ul li a,
  #cssmenu ul ul li:first-child > a,
  #cssmenu ul ul li:last-child > a {
    width: 100%;
    border-radius: 0;
    box-shadow: none;
    background: none;
  }
  #cssmenu ul li a {
    padding-left: 12.5px;
  }
  #cssmenu ul ul li a {
    padding: 14px 25px 14px 27.5px;
  }
  #cssmenu ul ul ul li a {
    padding-left: 42.5px;
  }
  #cssmenu ul ul ul ul li a {
    padding-left: 57.5px;
  }
  #cssmenu > ul > li.has-sub > a:after,
  #cssmenu > ul > li.has-sub > a:before,
  #cssmenu ul ul li.has-sub > a:after,
  #cssmenu ul ul li.has-sub > a:before {
    display: none;
  }
  #cssmenu #menu-button {
    position: relative;
    display: block;
    padding: 20px;
    padding-left: 12.5px;
    cursor: pointer;
    font-size: 13px;
    color: #ffffff;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
  }
  #cssmenu .submenu-button {
    position: absolute;
    right: 0;
    display: block;
    width: 53px;
    height: 53px;
    border-left: 1px solid rgba(120, 120, 120, 0.2);
    z-index: 10;
    cursor: pointer;
  }
  #cssmenu ul ul .submenu-button {
    height: 41px;
  }
  #cssmenu ul .submenu-button:after,
  #cssmenu #menu-button:after {
    content: '';
    position: absolute;
    right: 12.5px;
    top: 12.5px;
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 15px;
    background: #3db2e1;
    background: -webkit-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
    background: -ms-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
    background: -moz-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
    background: -o-linear-gradient(top, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
    background: linear-gradient(to bottom, #58bde5 0%, #4ab7e3 25%, #2babde 50%, #58bde5 75%, #4ab7e3 100%);
    box-shadow: inset 0 -1px 1px #209ed0, inset 0 2px 1px #7fcceb;
    background-size: 56px 56px;
    background-position: 0 0;
    background-repeat: no-repeat;
    -webkit-transition: all 0.1s ease-out;
    -moz-transition: all 0.1s ease-out;
    -ms-transition: all 0.1s ease-out;
    -o-transition: all 0.1s ease-out;
    transition: all 0.1s ease-out;
  }
  #cssmenu ul .submenu-button.submenu-opened:after,
  #cssmenu #menu-button.menu-opened:after {
    background-position: 0 -28px;
  }
  #cssmenu ul ul .submenu-button:after {
    top: 6.5px;
  }
  #cssmenu #menu-button:before,
  #cssmenu .submenu-button:before {
    content: '';
    position: absolute;
    right: 22.5px;
    top: 25.5px;
    display: block;
    width: 0;
    height: 0;
    border: 4px solid transparent;
    border-top-color: #ffffff;
    z-index: 99;
  }
  #cssmenu ul ul .submenu-button:before {
    top: 19.5px;
  }
  #cssmenu #menu-button.menu-opened:before,
  #cssmenu .submenu-button.submenu-opened:before {
    border-top-color: #19799f;
  }
}
&#13;
<div id='cssmenu' style='z-index: 9005'>
<ul>
   <li><a href='http://www.hmhao.blogspot.in/'>Home</a></li>
   <li class='active'><a href='#'>Movie Serie&#39;s</a>
      <ul>
         <li><a href='#'>300</a>
            <ul>
               <li><a href='#'>300 (2006)</a></li>
               <li><a href='#'>300 - Rise Of An Empire (2014)</a></li>
            </ul>
         </li>
         <li><a href='#'>30 Days Of Night</a>
            <ul>
               <li><a href='#'>30 Days Of Night (2007)</a></li>
               <li><a href='#'>30 Days Of Night - Dark Days (2010)</a></li>
            </ul>
         </li>
         <li><a href='#'>A Nightmare On Elm Street</a>
            <ul>
               <li><a href='#'>A Nightmare On Elm Street (1984)</a></li>
               <li><a href='#'>A Nightmare On Elm Street 4 - The Dream Master (1988)</a></li>
               <li><a href='#'>A Nightmare On Elm Street 5 - The Dream Child (1989)</a></li>
               <li><a href='#'>A Nightmare On Elm Street (2010)</a></li>
            </ul>
         </li>
         <li><a href='#'>Alien Vs Predator</a>
            <ul>
               <li><a href='#'>Alien Vs Predator (2004)</a></li>
               <li><a href='#'>Alien Vs Predator - Requiem (2007)</a></li>
            </ul>
         </li>
         <li><a href='#'>James Bond (007)</a>
            <ul>
               <li><a href='#'>Dr. No (1962)</a></li>
               <li><a href='#'>From Russia with Love (1963)</a></li>
               <li><a href='#'>Goldfinger (1964)</a></li>
               <li><a href='#'>Thunderball (1965)</a></li>
               <li><a href='#'>The Man with the Golden Gun (1974)</a></li>
               <li><a href='#'>The Spy Who Loved Me (1977)</a></li>
               <li><a href='#'>Moonraker (1979)</a></li>
               <li><a href='#'>For Your Eyes Only (1981)</a></li>
               <li><a href='#'>Never Say Never Again (1983)</a></li>
               <li><a href='#'>Octopussy (1983)</a></li>
               <li><a href='#'>A View to a Kill (1985)</a></li>
               <li><a href='#'>The Living Daylights (1987)</a></li>
               <li><a href='#'>Licence to Kill (1989)</a></li>
               <li><a href='#'>GoldenEye (1995)</a></li>
               <li><a href='#'>Tomorrow Never Dies (1997)</a></li>
               <li><a href='#'>The World Is Not Enough (1999)</a></li>
               <li><a href='#'>Die Another Day (2002)</a></li>
               <li><a href='#'>Casino Royale (2006)</a></li>
               <li><a href='#'>Quantum of Solace (2008)</a></li>
               <li><a href='#'>Skyfall (2012)</a></li>
            </ul>
         </li>
         <li><a href='#'>Back To The Future</a>
            <ul>
               <li><a href='#'>Back To The Future (1985)</a></li>
               <li><a href='#'>Back To The Future 2 (1989)</a></li>
               <li><a href='#'>Back To The Future 3 (1990)</a></li>
            </ul>
         </li>
         <li><a href='#'>Bad Boys</a>
            <ul>
               <li><a href='#'>Bad Boys (1995)</a></li>
               <li><a href='#'>Bad Boys 2 (2003)</a></li>
            </ul>
         </li>
         <li><a href='#'>Batman</a>
            <ul>
               <li><a href='#'>Batman Begins (2005)</a></li>
               <li><a href='#'>The Dark Knight (2008)</a></li>
               <li><a href='#'>The Dark Knight Rises (2012)</a></li>
            </ul>
         </li>
         <li><a href='#'>Blade</a>
            <ul>
               <li><a href='#'>Blade (1998)</a></li>
               <li><a href='#'>Blade 2 (2002)</a></li>
               <li><a href='#'>Blade - Trinity (2004)</a></li>
            </ul>
         </li>
         <li><a href='#'>Captain America</a>
            <ul>
               <li><a href='#'>Captain America - The First Avenger (2011)</a></li>
               <li><a href='#'>Captain America - The Winter Soldier (2014)</a></li>
            </ul>
         </li>
      </ul>
   </li>
      <li class='active'><a href='#'>0-9</a>
      <ul>
         <li><a href='#'>0</a></li>
         <li><a href='#'>1</a></li>
         <li><a href='#'>2</a></li>
         <li><a href='#'>3</a></li>
         <li><a href='#'>4</a></li>
         <li><a href='#'>5</a></li>
         <li><a href='#'>6</a></li>
         <li><a href='#'>7</a></li>
         <li><a href='#'>8</a></li>
         <li><a href='#'>9</a></li>
      </ul>
   </li>
&#13;
&#13;
&#13;

0 个答案:

没有答案
相关问题