0

根据我初始化 Superfish 的方式,我会在悬停时看到箭头或子菜单,但不能同时显示两者。

箭头将显示:(但没有子菜单)

<script>

jQuery(document).ready(function(){
    jQuery('#spice2011').superfish();
});

子菜单将显示:(但没有箭头)

<script>

jQuery(document).ready(function(){
    jQuery('ul.spice2011').superfish();
});

这是css,一定是罪魁祸首,但我看不到。我所做的只是添加 ul#spice2011 来定义导航宽度,但即使没有它,结果也与上述相同。我为箭头设置了绝对图像路径:

/*** ESSENTIAL STYLES ***/
ul#spice2011 {
width: 953px;   
}

.sf-menu, .sf-menu * {
margin: 0;
padding: 0;
list-style: none;
}
.sf-menu li {
position: relative;
}
.sf-menu ul {
position: absolute;
display: none;
top: 100%;
left: 0;
z-index: 99;
}
.sf-menu > li {
float: left;
}
.sf-menu li:hover > ul,
.sf-menu li.sfHover > ul {
display: block;
}

.sf-menu a {
display: block;
position: relative;
}
.sf-menu ul ul {
top: 0;
left: 100%;
}


/*** DEMO SKIN ***/
.sf-menu {
float: left;
margin-bottom: 1em;
}
.sf-menu ul {
box-shadow: 2px 2px 6px rgba(0,0,0,.2);
min-width: 12em; /* allow long menu items to determine submenu width */
*width: 12em; /* no auto sub width for IE7, see white-space comment below */
}
.sf-menu a {
border-left: 1px solid #fff;
border-top: 1px solid #dFeEFF; /* fallback colour must use full shorthand */
border-top: 1px solid rgba(255,255,255,.5);
padding: .75em 1em;
text-decoration:none;
zoom: 1; /* IE7 */
}
.sf-menu a {
color: #13a;
}
.sf-menu li {
background: #BDD2FF;
white-space: nowrap; /* no need for Supersubs plugin */
*white-space: normal; /* ...unless you support IE7 (let it wrap) */
-webkit-transition: background .2s;
transition: background .2s;
}
.sf-menu ul li {
background: #AABDE6;
}
.sf-menu ul ul li {
background: #9AAEDB;
}
.sf-menu li:hover,
.sf-menu li.sfHover {
background: #CFDEFF;
/* only transition out, not in */
-webkit-transition: none;
transition: none;
}

/*** arrows **/
.sf-menu a.sf-with-ul {
padding-right: 2.25em;
min-width: 1px; /* trigger IE7 hasLayout so spans position accurately */
}
.sf-sub-indicator {
position: absolute;
display: block;
right: .75em;
top: .9em;
width: 10px;
height: 10px;
text-indent: -999em;
overflow: hidden;
background: url(http://www.sea.edu/images/sea_images/arrows-ffffff.png) no-repeat 0 -100px;
}

li:hover > a .sf-sub-indicator,
li.sfHover > a .sf-sub-indicator {
background-position: -10px -100px;
}

/* point right for anchors in subs */
.sf-menu ul .sf-sub-indicator {
background-position: 0 0;
}
.sf-menu ul li:hover > a .sf-sub-indicator,
.sf-menu ul li.sfHover > a .sf-sub-indicator {
background-position: -10px 0;
}

这是代码,菜单是使用表达式引擎 2.4.0 动态创建的。因为它自动将列表项的内容包装在一个 div 中(我为第一个 li ul 模仿的,它不是动态创建的),我是否需要对 CSS 做一些激烈的事情来适应?

<nav>       
        <ul class="sf-menu" id="spice2011">
        <li>
            <a href="{site_url}spice_2011">2011</a>
                <ul>
                <li><a href="{site_url}spice_2012"><div>2012</div></a></li>
                <li><a href="{site_url}spice_2013"><div>2013</div></a></li>
                </ul>
            </li>
            <li><a href="{site_url}spice_2011/tahiti">Tahiti</a>
                <ul>
            {exp:channel:entries channel="spice_tahiti" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}         
            <li><a href="{url_title_path='spice_2011/tahiti_atlas'}">{alternate_title}</a></li>
            {/exp:channel:entries}
                </ul>
            </li>
            <li><a href="{site_url}spice_2011/moorea">Moorea</a>
                <ul>
            {exp:channel:entries channel="spice_moorea" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}         
            <li><a href="{url_title_path='spice_2011/moorea_atlas'}">{alternate_title}</a></li>
            {/exp:channel:entries}
                </ul>
            </li>
            <li><a href="{site_url}spice_2011/rangiroa">Rangiroa</a>
                <ul>
            {exp:channel:entries channel="spice_rangiroa" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}           
            <li><a href="{url_title_path='spice_2011/rangiroa_atlas'}">{alternate_title}</a></li>
            {/exp:channel:entries}
                </ul>
            </li>
            <li><a href="{site_url}spice_2011/nuku_hiva">Nuku Hiva</a>
                <ul>
            {exp:channel:entries channel="spice_nuku_hiva" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}          
            <li><a href="{url_title_path='spice_2011/nuku_hiva_atlas'}">{alternate_title}</a></li>
            {/exp:channel:entries}
                </ul>
            </li>               
            <li><a href="{site_url}spice_2011/kiritimati">Kiritimati</a>
                <ul>
            {exp:channel:entries channel="spice_kiritimati" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}         
            <li><a href="{url_title_path='spice_2011/kiritimati_atlas'}">{alternate_title}</a></li>
            {/exp:channel:entries}
                </ul>
            </li>
            <li><a href="{site_url}spice_2011/hawaii">Hawaii</a>
                <ul>
            {exp:channel:entries channel="spice_hawaii" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}         
            <li><a href="{url_title_path='spice_2011/hawaii_atlas'}">{alternate_title}</a></li>
            {/exp:channel:entries}
                </ul>   
            </li>
            <li><a href="{site_url}spice_2011/ship">Ship</a>
                <ul>
            {exp:channel:entries channel="spice_ship" category="not 268" disable="member_data|pagination" sort="desc" orderby="date"}           
            <li><a href="{url_title_path='spice_2011/ship_atlas'}">{alternate_title}</a></li>
            {/exp:channel:entries}
                </ul>   
            </li>
        </ul>
    </nav>
4

1 回答 1

1
jQuery(document).ready(function(){
    jQuery('ul#spice2011').superfish();
});
于 2013-04-10T21:58:43.473 回答