Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 下拉菜单位于其他元素后面或不工作_Html_Css_Drop Down Menu_Styling - Fatal编程技术网

Html 下拉菜单位于其他元素后面或不工作

Html 下拉菜单位于其他元素后面或不工作,html,css,drop-down-menu,styling,Html,Css,Drop Down Menu,Styling,因此,我正在为我的网站制作一个下拉菜单,所有的外观都很好,但是当我将鼠标悬停在上面时,它会出现,但当我将鼠标移到上面时,它就会消失。当我在“ul.menu li>a”下更改行高度时,它会起到一些作用,但不能解决我的问题。我试过“z-index”,但什么都没试过 这是我的css: ul.menu { display: inline; padding: 0px; margin: 0px; z-index:999; } #black_lay { display:none; position:

因此,我正在为我的网站制作一个下拉菜单,所有的外观都很好,但是当我将鼠标悬停在上面时,它会出现,但当我将鼠标移到上面时,它就会消失。当我在“ul.menu li>a”下更改行高度时,它会起到一些作用,但不能解决我的问题。我试过“z-index”,但什么都没试过

这是我的css:

ul.menu {
display: inline;    
padding: 0px;
margin: 0px;
z-index:999;
}

#black_lay {
display:none;
position: absolute;  /* makes the div go into a position that’s absolute to the browser viewing area */
left: 0%; /* makes the div span all the way across the viewing area */
top: 0%; /* makes the div span all the way across the viewing area */
background-color: black;
-moz-opacity: 0.7; /* makes the div transparent, so you have a cool overlay effect */
-webkit-opacity: 0.7;
opacity: .70;
filter: alpha(opacity=70);
width: 100%;
height: 100%;
z-index: 90; /* makes the div the second most top layer, so it’ll lay on top of everything else EXCEPT for divs with a higher z-index (meaning the #overlay ruleset) */
}

#overlay {
display: none; /* ensures it’s invisible until it’s called */
position: absolute; /* makes the div go into a position that’s absolute to the browser viewing area */
left: 25%; /* positions the div half way horizontally */
top: 25%; /* positions the div half way vertically */
padding: 25px; 
border: 2px solid black;
background-color: #ffffff;
width: 50%;
height: 50%;
z-index: 100; /* makes the div the top layer, so it’ll lay on top of the other content */
}

ul.menu li {
position:relative;
cursor: pointer;
-webkit-transition: padding .05s linear;
-moz-transition: padding .05s linear;
-ms-transition: padding .05s linear;
-o-transition: padding .05s linear;
transition: padding .05s linear;
}

ul.menu li.drop {
position: relative;
}

ul.menu > li {
display: inline-block;  
}

ul.menu li > a {
line-height: 80px;
padding: 0 1px;
-webkit-transition: all .1s ease-out;
-moz-transition: all .1s ease-out;
-ms-transition: all .1s ease-out;
-o-transition: all .1s ease-out;
transition: all .1s ease-out;
}

.dropOut .triangle {
width: 0;
height: 0;
position: absolute;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
border-bottom: 8px solid white;
top: -8px;
left: 50%;
margin-left: -8px;
}

.dropdownContain {
width: 160px;
position: absolute;
z-index: 9000000;
left: 50%;
margin-left: -80px; /* half of width */
top: -400px;
}

.dropOut {
width: 160px;
background: white;
float: left;
position: relative;
margin-top: 0px;
opacity: 0;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-box-shadow: 0 1px 6px rgba(0,0,0,.15);
-moz-box-shadow: 0 1px 6px rgba(0,0,0,.15);
box-shadow: 0 1px 6px rgba(0,0,0,.15);
-webkit-transition: all .1s ease-out;
-moz-transition: all .1s ease-out;
-ms-transition: all .1s ease-out;
-o-transition: all .1s ease-out;
transition: all .1s ease-out;
}

.dropOut ul > li {
list-style: none;   
}

.dropOut ul {
float: left;
padding: 10px 0;
 }

.dropOut ul li {
text-align: left;
float: left;
width: 125px;
padding: 12px 0 10px 15px;
margin: 0px 10px;
color: #777;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
-webkit-transition: background .1s ease-out;
-moz-transition: background .1s ease-out;
-ms-transition: background .1s ease-out;
-o-transition: background .1s ease-out;
transition: background .1s ease-out;
}

.dropOut ul li:hover {
background: #f6f6f6;
}

ul.menu li:hover a { color: white; }
ul.menu li:hover .dropdownContain { top: 45px; z-index: 500;}
ul.menu li:hover .underline { border-bottom-color: #777; }
ul.menu li:hover .dropOut { opacity: 1; margin-top: 15px; }
这是我的HTML:

 <nav style="display:inline">
        <ul class="menu">
            <li class="drop">
                <a>Username</a>
                <div class="dropdownContain">
                    <div class="dropOut">
                        <div class="triangle"></div>
                        <ul>
                            <li>Account</li>
                            <li>Logout</li>
                        </ul>
                    </div>
                </div>
            </li>
        </ul>
    </nav>

  • 用户名
    • 帐目
    • 注销

这应该是您的问题:

ul.menu li:hover a { color: white; }
它将选项卡的文本颜色更改为白色,就好像它不在那里一样


我在fiddle中将其更改为不同的颜色,效果很好。

当您将鼠标悬停在用户名选项卡上时,它丢失了,是吗?