显示无问题



我对网页设计很陌生,这是我设计的第二个符合我评估要求的网站,我无法让我的导航栏消失。我有"其他页面"我希望导航条在600px以下出现,在600px以上消失,我的ul导航条应该在600px以上出现,在600px以下消失。

很抱歉眼睛受伤了。

HTML

<ul>
<li><a class="active" href="index.html">Home</a></li>
<li><a href="html/aboutus.html">About Us</a></li>
<li><a href="html/menu.html">Menu</a></li>
<li><a href="html/zoo.html">Zoo</a></li>
<li><a href="html/parksandwalks.html">Parks and Walks</a></li>
</ul>
</div>
<div class="navbar">
<div class="dropdown">
<button class="dropbtn">Other Pages
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a class="active" href="index.html">Home</a>
<a href="../sunshine/html/aboutus.html">About Us</a>
<a href="../sunshine/html/menu.html">Menu</a>
<a href="../sunshine/html/zoo.html">Zoo</a>
<a href="../sunshine/html/parksandwalks.html">Parks and Walks</a>
</div>
</div>
</div>

CSS

.menu ul {
list-style-type: none;
margin: 0;
padding: 0;
}
.menu li {
padding: 8px;
margin-bottom: 7px;
background-color: #33b5e5;
color: #ffffff;
box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
}
.menu li:hover {
background-color: #0099cc;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333;
}
li {
float: left;
}
li a {
display: block;
color: white;
text-align: center;
padding: 20px 150px;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
@media only screen and (max-width: 600px) {
[class*="col-6"] {
width: 100%;
}
}
@media only screen and (max-width: 600px) {
li a {width: 100%}
}
@media only screen and (max-width: 600px) {
li a {text-align: center;}
}
@media only screen and (max-width: 600px) {
li {width: 100%}
}
@media screen and (max-width: 600px) {
.topnav a:not(:first-child) {display: none;}
.topnav a.icon {
float: right;
display: block;
}
}

@media screen and (max-width: 600px) {
.topnav.responsive {position: relative;}
.topnav.responsive a.icon {
position: absolute;
right: 0;
top: 0;
}

@media only screen and (max-width: 60px) {
div.navbar {
display: none;
}
}

@media only screen and (max-width: 60px) {
div.links {
display: none;
}
}   

.topnav.responsive a {
float: none;
display: block;
text-align: left;
}
}
/* Navbar container */
.navbar {
overflow: hidden;
background-color: #333;
font-family: Arial;
}
/* Links inside the navbar */
.navbar a {
float: left;
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* The dropdown container */
.dropdown {
width: 100%;
overflow: hidden;
text-align: center
}
/* Dropdown button */
.dropdown .dropbtn {
font-size: 16px;
width: 100%;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit; /* Important for vertical align on mobile phones */
margin: 0; /* Important for vertical align on mobile phones */
}
/* Add a red background color to navbar links on hover */
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
/* Dropdown content (hidden by default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
/* Add a grey background color to dropdown links on hover */
.dropdown-content a:hover {
background-color: #ddd;
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}

我为我造成的眼睛伤害道歉,是的,我从W3Schools复制了大部分内容。

try this

ul {
display:none;
flex-wrap:wrap;
list-style-type: none;
margin: 0;
padding: 0;
background-color: #333;
}
li a {
display: block;
color: white;
text-align: center;
padding: 20px 150px;
text-decoration: none;
}
li a:hover {
background-color: #111;
}
.navbar {
background-color: #333;
font-family: Arial;
}
/* Dropdown content (hidden by default) */
.dropdown-content {
display: none;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Links inside the navbar */
.navbar a {
font-size: 16px;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
}
/* Dropdown button */
.dropdown .dropbtn {
font-size: 16px;
width: 100%;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit; /* Important for vertical align on mobile phones */
margin: 0; /* Important for vertical align on mobile phones */
}
/* Add a red background color to navbar links on hover */
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: red;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Add a grey background color to dropdown links on hover */
.dropdown-content a:hover {
background-color: #ddd;
}
@media screen and (min-width: 600px) {
.navbar{display:none;}
ul{display:flex}
}
<div>
<ul>
<li><a class="active" href="index.html">Home</a></li>
<li><a href="html/aboutus.html">About Us</a></li>
<li><a href="html/menu.html">Menu</a></li>
<li><a href="html/zoo.html">Zoo</a></li>
<li><a href="html/parksandwalks.html">Parks and Walks</a></li>
</ul>
</div>
<div class="navbar">
<div class="dropdown">
<button class="dropbtn">Other Pages
<i class="fa fa-caret-down"></i>
</button>
<div class="dropdown-content">
<a class="active" href="index.html">Home</a>
<a href="../sunshine/html/aboutus.html">About Us</a>
<a href="../sunshine/html/menu.html">Menu</a>
<a href="../sunshine/html/zoo.html">Zoo</a>
<a href="../sunshine/html/parksandwalks.html">Parks and Walks</a>
</div>
</div>
</div>

最新更新