简体   繁体   English

在子菜单下方添加行

[英]Add line below the submenu

I want to add line under the submenu like shown in below picture. 我想在子菜单下添加行,如下图所示。 在此处输入图片说明 I am using wordpress and above menu made up from the plugin.What I have tried so far is that, 我正在使用wordpress以及由插件组成的菜单。到目前为止,我尝试过的是,

1) With CSS: 1)使用CSS:

I have added border-bottom to the submenu menu item list.But issue is border-bottom expand only to the list.Below image will give you more idea. 我在子菜单菜单列表中添加了border-bottom ,但是问题是border-bottom仅扩展到了列表。 在此处输入图片说明

在此处输入图片说明 2) With jQuery: 2)使用jQuery:

For jQuery, I have added <hr> just after the main-menu code.Like this : 对于jQuery,我在主菜单代码之后添加了<hr>

    $( "<hr />" ).insertAfter( "#mega-menu-primary-2" );

    $("li.mega-menu-megamenu a").each(function () {
    $("li.mega-menu-megamenu a").hover(function(){
        $("ul.mega-sub-menu > li > a").show("fade", 5000);
        $("hr").css({"display":"block"});
    },
    function(){$("hr").css({"display":"none"});});
    });

    $("ul.mega-sub-menu").hover(function(){
        $("hr").css({"display":"block"});
    },
    function(){$("hr").css({"display":"none"});});

Its working fine.But issue is that, when I hover on sub menu items, line just gets disappears. 它的工作正常。但是问题是,当我将鼠标悬停在子菜单项上时,行就消失了。 I have tried $("ul.mega-sub-menu > li >a").hover(function(){}); 我已经尝试过$("ul.mega-sub-menu > li >a").hover(function(){}); , but still same issue. ,但仍然是同一问题。

Can anyone guide me ? 谁能指导我?

NOTE: I have also tried with :after but nothing works perfectly. 注意:我也尝试过:after但是没有什么效果很好。

i think you have to add border bottom to submenu ul(un ordered list) not to the li elemnt and hr is not good solution also. 我认为您必须将边框底部添加到子菜单ul(无序列表)中,而不要添加限制,hr也不是一个好的解决方案。 pls can you save page as html and upload anywhere download able in order to make problem understandable 请您将网页另存为html并上传到任何地方都可以下载,以使问题易于理解

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM