开发者

CSS dropdown menu disappears when mouse moves off of <li>

开发者 https://www.devze.com 2023-01-15 02:53 出处:网络
I have the problem whereby I can\'t keep my sub menu visible. When I hover over the parent <li> it appears, and then when I move down to select one of the sub menu items it disappears. This 开发

I have the problem whereby I can't keep my sub menu visible. When I hover over the parent <li> it appears, and then when I move down to select one of the sub menu items it disappears. This 开发者_JAVA技巧is as soon as focus is lost from the parent <li>

I can't find a solution anywhere.

can someone please check it?

http://www.mymediaventure.com/about.php. It is under the Pricing tab. This is so frustrating. other examples I look at seem to work and I can't spot any clear differences that would hint why theirs works and mine doesn't.

Thanks in advance.


The problem is in styles.css and has to do with your #main_content h1 title element overlapping your div#primary_navigation. You can fix it by setting a higher z-index on your navigation element as I've done in the example below.

#wrapper #top #right div#primary_navigation
{
    position : relative;
    z-index: 2;
    font-size : 11pt;
    margin-top : 72px;

}

And a little further down in the CSS:

#main_content h1
{
    position : relative;
    z-index: 1;
    top : -20px;
    font-weight : normal;
}

If you want to visually see the problem, add a background colour to your #main_content h1 and you'll notice it almost completely overlaps your tabs. As a result you can trigger the dropdown when you hover over the top of the Pricing tab, but as you move down to the sub items, your mouse goes over the title and the menu disappears.


#main_content h1 {
font-weight:normal;
position:relative;
top:-20px;
}

THis is the problem, try deleting the position:relative, or change it to something else, ie:absolute


My solution to this was to expand the padding around the parent so that the selectable/hover region was larger.

In my case I set something like: .nav a {padding: 20px;}


I had a similar problem and I've found a solution for mine. Now I'm not versed in coding at all, some light Dreamweaver, but that's about it. I was having this problem with a tumblr theme and none of these solutions worked. Only after changing top: 25px; to top: 20px;, the dropdown did work for my site. Hope this helps someone.


I followed the advice of the previous poster but with modifications. I changed all of my relative positioning to absolute for all items on the page (header, menu, and content) and this fixed the menu problem. I had to change for all three items for the menu to stop disappearing on mouseover.


I had a margin set on the <ul> which I removed and put on a div containing the <ul>.

anyway I managed to get a drop down menu from image hover effect, example and example code here dropdown menu from custom button image hover

I hope this helps someone


I had a similar problem: a drop down menu disappeared when the mouse pointer hovered over a part of the drop down menu at which underneath a adsense ad was shown. Putting the ad down in the html page solved the issue. Did not try out other solutions.


I also had this problem. The problem was that there was a space between where the main menu ended and where the dropdown menu began, so while moving the nouse down to the dropdown options, it would pass over an area of the background and the menu would disappear.

The fix was adjusting the top position as shown below (in my case, from 4.0 to 3.75em)

.main-navigation ul ul {
            position: absolute;
        top: 3.75em;


I had the same problem with the secondary hover navigation going away when i tried to move from the primary to the secondary menu. What seemed to help for me was to move the margin up into the primary menu. I added the following line to my already existing ul li ul { margin-top: -.1em; }

0

精彩评论

暂无评论...
验证码 换一张
取 消