长下拉菜单解决方案

发布于 2024-08-12 04:00:23 字数 403 浏览 3 评论 0原文

来自 css-tricks.com 的 Chris 为长下拉菜单创建了一个漂亮的解决方案:此处

我在以下页面上实现了此功能:onomadesign.com/wordpress/portfolio/identity-design,位于右上角。

但我希望这个子菜单始终可见,因此无需单击“项目”。

有人可以帮我吗?我绝对不是 jQuery 专业人士。谢谢。

Chris from css-tricks.com created a beautiful solution for long dropdown menu's: here

I implemented this on the following page: onomadesign.com/wordpress/portfolio/identity-design, on the upper right side.

But I want this submenu to be visible all the time, so there is no need for clicking 'projects'.

Could someone help me with that? I'm definitly not a jQuery pro. Thank you.

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

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

发布评论

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

评论(2

丑疤怪 2024-08-19 04:00:23

这可能不是一个很好的答案,但它有效:

<script type="text/javascript" charset="utf-8">     
    $(document).ready(function() {      

        $('.dropdown > li').longDropdown({
            visible: 50
        });         
        $('.margin').live(function() {              
            $this = $(this);                
            $("body").css('marginTop', $this.attr('rel') + 'px');
            return false;
        });

            $('.dropdown a:first').click(); 

    });
</script>

This probly isn't a great answer, but it works:

<script type="text/javascript" charset="utf-8">     
    $(document).ready(function() {      

        $('.dropdown > li').longDropdown({
            visible: 50
        });         
        $('.margin').live(function() {              
            $this = $(this);                
            $("body").css('marginTop', $this.attr('rel') + 'px');
            return false;
        });

            $('.dropdown a:first').click(); 

    });
</script>
愚人国度 2024-08-19 04:00:23

您可以执行以下操作吗:

$(function(){
    $('#sub_menu).show();
});

此时您可以删除“项目”链接的锚标记。如果这对您不起作用,请告诉我。

编辑:

您也可以尝试:

$('#sub_menu').css({height:400,overflow:'hidden'}).show();

如果您从 jQuery 插件切换到可从您链接的站点下载的常规 JS 文件,它似乎可以在 FF 和 IE 中工作。这样做的问题是,当您将鼠标移出下拉菜单时,下拉菜单将消失。对我来说,这是可取的,因为当用户第一次看到该页面时它是打开的,但可以通过将鼠标悬停在其上然后将鼠标移开来隐藏。如果您希望它始终保持打开状态,可以使用以下代码:

$('.dropdown > li').bind('mouseleave', function(event) {
    $('#sub_menu').css({height:400,overflow:'hidden'}).show();
});

这应该可以解决问题。

Can you just do something like:

$(function(){
    $('#sub_menu).show();
});

At that point you may then be able to remove the anchor tag for the "projects" link. Let me know if that doesn't work for you.

EDIT:

You could also try:

$('#sub_menu').css({height:400,overflow:'hidden'}).show();

which appears to work in both FF and IE if you switch from the jQuery plugin to the regular JS file that is downloadable from the site you linked. The issue with this is that the dropdown will disappear when you mouse out of the drop down. To me, this is desirable since it's open when the user first sees the page but can be hidden by mousing over it and then mousing away. If you want it to always stay open, you can use the following code:

$('.dropdown > li').bind('mouseleave', function(event) {
    $('#sub_menu').css({height:400,overflow:'hidden'}).show();
});

which should do the trick.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文