希望有人能发现我所缺少的东西,我正在同时处理topnav和sidenav的页面。我希望topnav保持领先于一切。我希望将sidenav置于其下方,而不使其重叠。
这是我的fiddle,您可以通过点击橙色汉堡包按钮来访问sidenav。
我以前曾经使用过它,但是最近我对topnav做了一些调整,现在它只是拒绝合作。任何帮助,请您感激。
这是CSS:
body {
margin:0;
color: #2C3E60;
font-size: ;
font-family: arial;
font-weight: bold;
font-family: ;
line-height: 1.2;
overflow: hidden;
}
form {
margin: 0px;
padding: 0px;
}
.main {
padding: 0px;
margin-top: 0px;
width: 100%;
height: 91%;
position:absolute;
overflow-y:auto;
background-color: #ec7c23;
}
.navbar {
overflow: hidden;
background-color: #577CC1;
min-height: 71px;
possition: fixed;
/*z-index: 2;*/
top: 0;
width: 100%;
line-height: 1.07;
font-size: 3em;
}
.navbar a {
float: left;
display: block;
color: #ffffff;
text-align: center;
padding: 10px 10px;
text-decoration: ;
font-size: 40px;
font-weight: bold;
}
.active {
background-color: #4CAF50;
color: white;
}
.navbar .icon {
display: none;
}
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
font-weight: bold;
margin: 0;
height: 71px;
}
.dropdown-content {
display: none;
position: absolute;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
background-color: rgba(0, 42, 59, .8);
overflow: auto;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.dropdown-content a {
float: none;
color: #ffffff;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
font-size: 20px;
font-weight: bold;
}
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: ;
color: white;
}
.dropbtn a:hover, .dropdown:hover .dropbtn {
background-color: #2C3E60;
color: white;
}
.dropdown-content a:hover {
background-color: #577CC180;
color: black;
}
.dropdown:hover .dropdown-content {
display: block;
}
@media screen and (max-width: 600px) {
.navbar a:not(:first-child), .dropdown .dropbtn {
display: none;
}
.navbar a.icon {
float: right;
display: block;
}
}
@media screen and (max-width: 600px) {
.navbar.responsive {position: relative;}
.navbar.responsive .icon {
position: absolute;
right: 0;
top: 0;
}
.navbar.responsive a {
float: none;
display: block;
text-align: left;
color: white;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.navbar.responsive .dropdown {float: none ;
}
.navbar.responsive .dropdown-content {
position: relative;
border-bottom-left-radius: 0px;
border-bottom-right-radius: 0px;
}
.navbar.responsive .dropdown .dropbtn {
display: block;
width: 100%;
text-align: left;
}
}
.container {
display: inline-block;
cursor: pointer;
float: right;
}
.bar1, .bar2, .bar3 {
width: 35px;
height: 5px;
background-color: #ec7c23;
margin: 6px 0;
transition: 0.4s;
}
.change .bar1 {
-webkit-transform: rotate(-45deg) translate(-9px, 6px) ;
transform: rotate(-45deg) translate(-9px, 6px) ;
}
.change .bar2 {opacity: 0;}
.change .bar3 {
-webkit-transform: rotate(45deg) translate(-8px, -8px) ;
transform: rotate(45deg) translate(-8px, -8px) ;
}
.sidenav {
height: 100%;
width: 0;
position: fixed;
z-index: 9;
top: 0;
right: 0;
background-color: rgba(0, 42, 59, .8);
font-weight: ;
overflow-x: hidden;
transition: 0.5s;
padding-top: 60px;
}
.sidenav a {
padding: 8px 8px 8px 32px;
text-decoration: none;
font-size: 25px;
color: #577CC1;
display: block;
transition: 0.3s;
}
.sidenav a:hover, .offcanvas a:focus{
color: #ec7c23;
}
.sidenav .closebtn {
position: absolute;
top: 0;
right: 25px;
font-size: 36px;
margin-left: 50px;
z-index: 10;
}
@media screen and (max-height: 450px) {
.sidenav {padding-top: 15px;}
.sidenav a {font-size: 18px;}
button.accordion {
background-color: #577CC1;
color: white;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
font-family: arial;
font-weight: bold;
line-height: 1.2;
transition: 0.4s;
z-index: 5;
}
button.accordion.active, button.accordion:hover {
background-color: #2C3E60;
}
div.panel {
padding: 0 18px;
display: none;
background-color: rgba(0, 0, 0, 0.0);
color: #2C3E60;
font-size: ;
font-family: arial;
font-weight: bold;
line-height: 1.2;
}
答案 0 :(得分:1)
只需更正您的.navbar
类中的错字
possition: fixed;
至position: fixed;