gpt4 book ai didi

javascript - 无法在 Chrome 浏览器中查看我的下拉菜单,但是当我在此处插入代码时,我可以查看它。怎么会?

转载 作者:搜寻专家 更新时间:2023-10-31 22:40:06 26 4
gpt4 key购买 nike

我有下面的代码,但是,当我用 visual studio code 修改代码并在我的 Chrome 浏览器中运行它时,我在“热门产品”中看不到下拉菜单。部分。

但是,当我在此处 (stackoverflow) 插入代码时,我可以看到我的下拉菜单。有人可以向我解释这是怎么发生的吗?我该如何解决这个问题,以便我可以在所有类型的浏览器中查看它?非常感谢!

body {
background-color: white;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}

/* Navigation bar */
#navigation_bar {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}

li {
float: left;

}

li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover:not(.active), .dropdown:hover .dropbtn {
background-color: #111;
}

li.dropdown {
display: inline-block;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #4CAF50;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

.dropdown-content a:hover {
background-color: #f1f1f1
}

.dropdown:hover .dropdown-content {
display: block;
}

.active {
background-color: #4CAF50;
}
<!DOCTYPE html>
<html>
<head>
<title>Bo Kei Restaurant</title>
<link rel='stylesheet' type='text/css' href='stylesheet.css'/>
<script type='text/javascript' src='javascript/jquery-3.1.0.js'></script>
<script type='text/javascript' src='javascript/jquery-ui.min.js'></script>
<script type='text/javascript' src='javascript/script.js'></script>
</head>
<body>

<!--Navigation bar-->
<ul id="navigation_bar">
<li><a class="active" href="navigation_bar/home.html">Home.</a></li>
<li><a href="navigation_bar/promotion.html">Promotion.</a></li>
<!--drop down menu-->
<li class="dropdown"><a href="navigation_bar/hot_products.html" class="dropbtn">Hot Products.</a>
<div class="dropdown-content">
<a herf="navigation_bar/sub_menu/sandwiches.html">Sandwiches</a>
<a herf="navigation_bar/sub_menu/burger.html">Burger</a>
<a herf="navigation_bar/sub_menu/rice.html">Rice</a>
<a herf="navigation_bar/sub_menu/noodles.html">Noddles</a>
</div>
</li>
<!--Back to normal-->
<li><a href="navigation_bar/cold_products.html">Cold Products.</a></li>
<li><a href="navigation_bar/snacks.html">Snacks.</a></li>
<li><a href="navigation_bar/about_us.html">About Us.</a></li>
<li><a href="navigation_bar/contact_us.html">Contact Us.</a></li>
</ul>



</body>
</html>

最佳答案

我在这里看不到下拉菜单...只需从 #navigation_bar 中删除 overflow: hidden,它应该可以正常工作:

body {
background-color: white;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
}

/* Navigation bar */
#navigation_bar {
list-style-type: none;
margin: 0;
padding: 0;
background-color: #333;
position: fixed;
top: 0;
width: 100%;
}

li {
float: left;

}

li a, .dropbtn {
display: inline-block;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}

li a:hover:not(.active), .dropdown:hover .dropbtn {
background-color: #111;
}

li.dropdown {
display: inline-block;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #4CAF50;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}

.dropdown-content a:hover {
background-color: #f1f1f1
}

.dropdown:hover .dropdown-content {
display: block;
}

.active {
background-color: #4CAF50;
}
<!DOCTYPE html>
<html>
<head>
<title>Bo Kei Restaurant</title>
<link rel='stylesheet' type='text/css' href='stylesheet.css'/>
<script type='text/javascript' src='javascript/jquery-3.1.0.js'></script>
<script type='text/javascript' src='javascript/jquery-ui.min.js'></script>
<script type='text/javascript' src='javascript/script.js'></script>
</head>
<body>

<!--Navigation bar-->
<ul id="navigation_bar">
<li><a class="active" href="navigation_bar/home.html">Home.</a></li>
<li><a href="navigation_bar/promotion.html">Promotion.</a></li>
<!--drop down menu-->
<li class="dropdown"><a href="navigation_bar/hot_products.html" class="dropbtn">Hot Products.</a>
<div class="dropdown-content">
<a herf="navigation_bar/sub_menu/sandwiches.html">Sandwiches</a>
<a herf="navigation_bar/sub_menu/burger.html">Burger</a>
<a herf="navigation_bar/sub_menu/rice.html">Rice</a>
<a herf="navigation_bar/sub_menu/noodles.html">Noddles</a>
</div>
</li>
<!--Back to normal-->
<li><a href="navigation_bar/cold_products.html">Cold Products.</a></li>
<li><a href="navigation_bar/snacks.html">Snacks.</a></li>
<li><a href="navigation_bar/about_us.html">About Us.</a></li>
<li><a href="navigation_bar/contact_us.html">Contact Us.</a></li>
</ul>



</body>
</html>

关于javascript - 无法在 Chrome 浏览器中查看我的下拉菜单,但是当我在此处插入代码时,我可以查看它。怎么会?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38847969/

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