如何纠正水平 2 级 superfish 菜单中的样式

发布于 2025-01-07 00:25:47 字数 312 浏览 0 评论 0原文

我有一个有两层的水平超级鱼菜单。当我将鼠标悬停在第一级链接上时,第二级下拉菜单看起来比顶级链接的底部低约 2em,尽管 firebug 说样式是:

.sf-menu li:hover > ul, .sf-menu li.sfHover > ul {
    left: 0;
    bottom: 0em;
}

无论我尝试提高底部位置多少(例如底部:-2.5) em),二级菜单不会升起。这让我认为浏览器(Firefox)可能会造成差距,但我找不到这方面的证据。

我怎样才能克服这个不正确的定位或找出可能的原因?

I have a horizontal superfish menu with two levels. When I hover over a first level link, the second level drop down appears approx 2ems lower than the bottom of top level links although firebug says the style is:

.sf-menu li:hover > ul, .sf-menu li.sfHover > ul {
    left: 0;
    bottom: 0em;
}

No matter how much I try to raise the bottom position (eg. bottom: -2.5em), the second level menu will not raise up. This leads me to think that the browser (Firefox) may be forcing a gap, but I cannot find evidence of that.

How can I override this incorrect positioning or find out what might be the cause?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌若浮生 2025-01-14 00:25:47

您可以发布您网站的链接吗?

具体回答有点棘手......但作为猜测尝试定位:

.sf-menu ul a {

这是一些很好的、颜色清晰的CSS来帮助你,它可能很难得到掌握 superfish css...

主题皮肤:

/*** COLOR SKIN ***/

/* main ul element */
.sf-menu {
    border-right: 1px solid FUCHSIA;
    float:left;
}

/* general link styles*/
.sf-menu a {
    display: block;
    padding:9px 13px;
    text-decoration:none;
    border-top: 1px solid;
    border-left: 1px solid;
    border-bottom: 1px solid;
}

/*** 1st Level ***/

/* 1st level links, no hover, no visits */
.sf-menu li a {
    color: yellow;
    background-color: green;
    border-color: red;
}
/* 1st level links, while hovering over sub menu */
.sf-menu li.sfHover a{
    color: black;
    background-color: silver;
}

/* 1st level links, hover */
.sf-menu li a:hover {
    color: white;
    background-color: lime;
}

/* 1st level current page */
.sf-menu .current_page_item a,
.sf-menu .current_page_ancestor a,
.sf-menu .current_page_parent a {
    border-bottom-color: white;
    background-color: TEAL;
}

/* 1st level down triangles with pure css*/
.sf-menu li .sf-sub-indicator {
    text-indent:-9999px;
    line-height: 0;
    border-color:YELLOW transparent transparent;
    border-style:solid;
    border-width:4px; /*controls size of triangle */
    display:inline-block;
    margin-left:5px;
}

/*** 2nd level ***/

/* sub menu */
.sf-menu ul {
    border-right:1px solid;
    border-bottom:1px solid;
    border-color: yellow;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
    top:32px; /* overriding essential styles- adjust if you have gaps between first level and drop-down sub menu*/
}
.sf-menu ul ul {
    margin-top:0; /*unlikely to need adjusting */
}

/* 2nd level links, no hover */
.sf-menu li li a, .sf-menu li.sfHover li a {
    color: orange;
    background-color: blue;
    border-color: green;
    border-bottom: 0;
}

/* 2nd level links, while hovering over sub menu */
.sf-menu li li.sfHover a{
    color: black;
    background-color: silver;
}

/* 2nd level links, hover */
.sf-menu li li a:hover, .sf-menu li.sfHover li a:hover {
    color: white;
    background-color: aqua;
}

/* 2nd level current page */
.sf-menu li li.current_page_item a,
.sf-menu li li.current_page_ancestor a,
.sf-menu li li.current_page_parent a {
    background-color: TEAL;
}

/* 2nd level side triangles with pure CSS */
.sf-menu li li .sf-sub-indicator { /*right arrow*/
    border-color: transparent transparent transparent WHITE;
}

/*** 3rd Level and beyond ***/

/* 3rd level links, no hover */
.sf-menu li li li a, .sf-menu li.sfHover li li a {
    color: blue;
    background-color: red;
    border-color: blue;
}

/* 3rd level links, hover */
.sf-menu li li li a:hover, .sf-menu li.sfHover li li a:hover {
    color: white;
    background-color: pink;
}

/* 2nd level current page */
.sf-menu li li li.current_page_item a,
.sf-menu li li li.current_page_ancestor a,
.sf-menu li li li.current_page_parent a {
    background-color: TEAL;
}

Can you post a link to your site?

Its a bit tricky to answer specifically.... but as a guess try targeting:

.sf-menu ul a {

This is some good , clearly coloured css to help you, it can be tricky to get to grips with superfish css...

Theme skin:

/*** COLOR SKIN ***/

/* main ul element */
.sf-menu {
    border-right: 1px solid FUCHSIA;
    float:left;
}

/* general link styles*/
.sf-menu a {
    display: block;
    padding:9px 13px;
    text-decoration:none;
    border-top: 1px solid;
    border-left: 1px solid;
    border-bottom: 1px solid;
}

/*** 1st Level ***/

/* 1st level links, no hover, no visits */
.sf-menu li a {
    color: yellow;
    background-color: green;
    border-color: red;
}
/* 1st level links, while hovering over sub menu */
.sf-menu li.sfHover a{
    color: black;
    background-color: silver;
}

/* 1st level links, hover */
.sf-menu li a:hover {
    color: white;
    background-color: lime;
}

/* 1st level current page */
.sf-menu .current_page_item a,
.sf-menu .current_page_ancestor a,
.sf-menu .current_page_parent a {
    border-bottom-color: white;
    background-color: TEAL;
}

/* 1st level down triangles with pure css*/
.sf-menu li .sf-sub-indicator {
    text-indent:-9999px;
    line-height: 0;
    border-color:YELLOW transparent transparent;
    border-style:solid;
    border-width:4px; /*controls size of triangle */
    display:inline-block;
    margin-left:5px;
}

/*** 2nd level ***/

/* sub menu */
.sf-menu ul {
    border-right:1px solid;
    border-bottom:1px solid;
    border-color: yellow;
}
.sf-menu li:hover ul,
.sf-menu li.sfHover ul {
    top:32px; /* overriding essential styles- adjust if you have gaps between first level and drop-down sub menu*/
}
.sf-menu ul ul {
    margin-top:0; /*unlikely to need adjusting */
}

/* 2nd level links, no hover */
.sf-menu li li a, .sf-menu li.sfHover li a {
    color: orange;
    background-color: blue;
    border-color: green;
    border-bottom: 0;
}

/* 2nd level links, while hovering over sub menu */
.sf-menu li li.sfHover a{
    color: black;
    background-color: silver;
}

/* 2nd level links, hover */
.sf-menu li li a:hover, .sf-menu li.sfHover li a:hover {
    color: white;
    background-color: aqua;
}

/* 2nd level current page */
.sf-menu li li.current_page_item a,
.sf-menu li li.current_page_ancestor a,
.sf-menu li li.current_page_parent a {
    background-color: TEAL;
}

/* 2nd level side triangles with pure CSS */
.sf-menu li li .sf-sub-indicator { /*right arrow*/
    border-color: transparent transparent transparent WHITE;
}

/*** 3rd Level and beyond ***/

/* 3rd level links, no hover */
.sf-menu li li li a, .sf-menu li.sfHover li li a {
    color: blue;
    background-color: red;
    border-color: blue;
}

/* 3rd level links, hover */
.sf-menu li li li a:hover, .sf-menu li.sfHover li li a:hover {
    color: white;
    background-color: pink;
}

/* 2nd level current page */
.sf-menu li li li.current_page_item a,
.sf-menu li li li.current_page_ancestor a,
.sf-menu li li li.current_page_parent a {
    background-color: TEAL;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文