【问题标题】:Right align Superfish menu - and stop it jumping around右对齐 Superfish 菜单 - 并阻止它跳来跳去
【发布时间】:2011-10-22 01:47:07
【问题描述】:

我真的很想阻止菜单项在 on this site 周围跳跃,因为父项会展开以适应其子项。

当我添加这个 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 实现我想要的?我希望如此!

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

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

【问题讨论】:

    标签: css superfish submenu


    【解决方案1】:

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

    此版本使用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;
    }
    

    【讨论】:

    • 感谢@Phatograph,但也许我没有正确解释自己。我希望下拉效果保持不变,子菜单在自己的行上。我只是不想说“工作”在您滚动“实验室”或“关于”时跳到左边,当您滚动“关于”时说“实验室”。
    • 让我再试一次,见上:)
    • 就是这样!通过一些调整,它几乎可以满足我现在的需求。谢谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多