0

当父项扩展以适应其子项时,我真的很想停止在此站点上跳来跳去的菜单项。

当我添加这个 CSS 时,我可以让它看起来像我想要的那样,强制菜单项具有固定的宽度:

/*Menu item 1*/
#menu-item-117 .sub-menu {right: -125px;}
/*Menu item 2*/
#menu-item-73 {width:45px;}
#menu-item-73 .sub-menu {width:980px!important;right: -10px;}
/*Menu item 3*/
#menu-item-122 {width:65px;}
#menu-item-122 .sub-menu{width:980px!important;right: 165px;}

然而,这显然并不理想,因为菜单需要是动态的......

有没有办法通过 CSS 实现我想要的?但愿如此!

我正在使用Theme Hybrid for Wordpress 附带的 Superfish 菜单。

提前感谢您提供的任何帮助!

4

1 回答 1

0

我明白你的意思..让我们再看看。

此构建使用position: relative/absolute;代替,float: right/left;并且它具有以下提到的一个缺陷。

但是我还没有在包括 IE 在内的旧浏览器(在 Chrome 和 Firefox 中测试)中对此进行测试,但我希望这可以为您提供一些实现它的想法。:)

#primary-menu .menu /* new rule */ {
  position: relative;
  height: 50px; /* The flaw is you have to fix the menu's height here */
}

#primary-menu ul {
    position: absolute;
    right: 0;
    top: 0;
}

#primary-menu li {
    float: left;
    list-style: none outside none;
    margin-left: 10px;
    position: relative;
}

.sub-menu {
    background: none repeat scroll 0 0 #244563;
    clear: both;
    display: none;
    font-size: 0.8em;
    overflow: visible;
    padding: 5px 0 !important;
    position: relative;
    right: 0;
    text-align: right;
    top: 30px !important;
    width: 700px !important;
}

.sub-menu li {
    display: inline !important;
    float: none !important;
    padding: 10px 0 !important;
    width: auto !important;
}
于 2011-10-21T04:31:34.107 回答