gpt4 book ai didi

html - 为什么我的导航栏不会下拉?

转载 作者:太空宇宙 更新时间:2023-11-04 12:58:28 25 4
gpt4 key购买 nike

我的导航栏不会下拉。任何人都可以帮忙吗?我创建了一个导航栏,但现在我试图让它的一部分成为下拉菜单,但它并没有下拉。我已经包含了我的 html 和 CSS 代码。

提前致谢

我的代码:

CSS:

@charset "utf-8";
/* CSS Document */

body {
margin - top: 0px;
margin - bottom: 0px;
margin - left: 0px;
margin - right: 0px;
}

html {
background: url(devbackground.jpg) no - repeat center center fixed;
- webkit - background - size: cover;
- moz - background - size: cover;
- o - background - size: cover;
background - size: cover;
filter: progid: DXImageTransform.Microsoft.AlphaImageLoader(src = 'devbackground.jpg', sizingMethod = 'scale');
- ms - filer: "progid:DXImageTransform.Microsoft.AlphaImageLoader (src='devbackground.jpg', sizingMethod='scale')";
}

img.bg {
/*set rules to fill background */
min - height: 100 %;
min - width: 1024px;
/*set up proportiante scaling */
width: 100 %;
height: auto;
/*set up positioning */
position: fixed;
top: 0;
left: 10;
}

/*nav bar code */

ul# list - nav {
list - style: none;
width: 1200px;
margin - bottom: 20px;
/*height of the nav bar */
margin - left: 450px;
/
margin-right: 450px;
margin-top: 20px;
padding-bottom: 0;
padding-left: 0;
padding-right: 0px;
padding-top: 0;
}

ul#list-nav li {
display: inline;
}

ul#list-nav li a {
/ * nav bar boxes * /
text-decoration: none;
width: 200px;
height: auto;
background: #485e49;
color: #eee;
float: left;
text-align: center;
border-left: 1px solid #fff;
padding-bottom: 5px;
padding-left: 0;
padding-right: auto;
padding-top: 5px;
}

ul#list-nav li a:hover {
background: #a2b3a1;
color: #000;
}

#list-nav, #list-nav ul {
margin: 0 auto;
padding: 0;
}

#list-nav li {
float: left;
position: relative;
list-style: none;
}

#list-nav > li:hover > ul {
display: block;
}

#list-nav > li > ul {
display: none;
position: absolute;
}

#list-nav li a {
white-space: nowrap;
}

HTML:

<!doctype html>
<html>

<head>

<link rel="stylesheet" type="text/css" href="css.css">
<meta charset="utf-8">
<title>Welcome to dcoltgaming.co.uk</title>
</head>

<body>

<ul id="list-nav">

<li><a href="/">Home</a>
</li>
<li><a href="#">Stuff</a>

<ul>
<li><a href="navbartest.html">NavBar Test</a>
</li>
</ul>

</li>

<li><a href="#">More Stuff</a>
</li>
<li><a href="#">Guess what? thats right more stuff!!!!!</a>
</li>
<li><a href="troll.html">Troll Faces</a>
</li>
</ul>
</body>

</html>K
<!doctype html>
<html>

<head>

<link rel="stylesheet" type="text/css" href="css.css">
<meta charset="utf-8">
<title>Welcome to dcoltgaming.co.uk</title>
</head>

<body>

<ul id="list-nav">

<li><a href="/">Home</a>
</li>
<li><a href="#">Stuff</a>

<ul>
<li><a href="navbartest.html">NavBar Test</a>
</li>
</ul>

</li>

<li><a href="#">More Stuff</a>
</li>
<li><a href="#">Guess what? thats right more stuff!!!!!</a>
</li>
<li><a href="troll.html">Troll Faces</a>
</li>
</ul>
</body>
</html>

最佳答案

这是因为您的子 UL 具有绝对定位,从技术上讲它是“下降”,但由于辅助 UL 是绝对定位的,它只是覆盖了初始导航栏。将 margin-top:29px; 添加到您的辅助 UL,它将起作用。

JSFiddle

关于html - 为什么我的导航栏不会下拉?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25628280/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com