如何重叠我的幻灯片导航?我在下面列出了我的网页的简化版本。我相信div #MainMenu
的位置必须保持为position: fixed
,就好像它不会像这样,如果我将位置设置为绝对位置或类似位置,则导航将具有浮动底部。 div #centeralign
已设置为position: relative
。
$(document).ready(function() {
$("#MenuIcon").click(function() {
$("#MainMenu").css("left", "0px");
$("#MOVE").css("left", "300px");
function showMenu() {
$("#MainMenu").css("-webkit-clip-path", "polygon(0 0,100% 0,100% 100%,0% 100%)");
$("#MenuIcon").animate({
right: '-100'
}, 300);
}
setTimeout(showMenu, 100);
});
$("#close").click(function() {
$("#MainMenu").css("-webkit-clip-path", "polygon(0 0,0% 0,100% 100%,0% 100%)");
function hideMenu() {
$("#MainMenu").css("left", "-300px");
$("#MOVE").css("left", "0px")
$("#MenuIcon").animate({
right: '50'
}, 300);
}
setTimeout(hideMenu, 300);
function originalLayout() {
$("#MainMenu").css("-webkit-clip-path", "polygon(0 0,100% 0,0% 100%,0% 100%)");
}
setTimeout(originalLayout, 600);
});
});

body {
background-color: purple;
}
h1 {
color: #e5b78e;
font-family: Arial;
font-size: 100pt;
padding: 0px;
margin: 0px;
display: block;
}
.button {
display: inline-block;
background: transparent;
text-transform: uppercase;
font-weight: bold;
font-style: normal;
font-family: Arial;
font-size: 2em;
letter-spacing: 0.2em;
color: rgba(223, 190, 106, 0.7);
border-radius: 0;
padding: 18px 80px 20px;
transition: all 0.7s ease-out;
background: linear-gradient(270deg, rgba(223, 190, 106, 0.8), rgba(146, 111, 52, 0.8), rgba(34, 34, 34, 0), rgba(34, 34, 34, 0));
background-position: 1% 50%;
background-size: 300% 300%;
text-decoration: none;
margin: 0.625rem;
border: none;
border: 1px solid rgba(223, 190, 106, 0.3);
}
.button:hover {
color: #fff;
border: 1px solid rgba(223, 190, 106, 0);
color: $white;
background-position: 99% 50%;
}
#btn1 {
margin-top: 30px;
display: inline-block;
padding-left: 30px;
padding-right: 30px;
}
#btn2 {
margin-top: 30px;
display: inline-block;
padding-left: 47px;
padding-right: 47px;
}
.button:hover {
opacity: 1;
transition: opacity .2s ease-in;
}
#centeralign {
text-align: center;
top: 20em;
position: relative;
transition: all .5s ease-in-out;
}
br {
padding: 40px;
}
/* NAV */
#MenuIcon {
height: 25px;
width: 50px;
position: fixed;
top: 50;
right: 50;
}
#MenuIcon:hover {
cursor: pointer;
}
#MenuLine {
height: 4px;
width: 50px;
background-color: #e5b78e;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition: all .3s;
}
#MenuIcon:hover #MenuLine {
width: 40px;
}
#MenuLine::before {
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: 10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::before {
width: 50px;
}
#MenuLine::after {
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: -10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::after {
width: 50px;
}
#MainMenu {
height: 100vh;
width: 300px;
background-color: #181818;
-webkit-clip-path: polygon(0 0, 100% 0, 0% 100%, 0% 100%);
position: fixed;
top: 0;
left: -300px;
transition: all .5s ease-in-out;
}
ul {
list-style: none;
padding: 0px;
margin: 0px;
font-family: arial;
font-weight: bold;
color: white;
text-align: center;
position: absolute;
top: 55%;
left: 50%;
transform: translate(-50%, -50%);
}
ul li {
margin: 20px;
}
ul li:hover {
cursor: pointer;
}
.line {
height: 2px;
width: 150px;
background-color: white;
margin-top: 10px;
position: absolute;
left: 50%;
transform: translate(-50%);
transition: all .3s;
}
ul li:hover .line {
width: 180px;
}
#logo {
position: absolute;
top: 10%;
left: 50%;
transform: translate(-50%);
}
#close {
position: absolute;
bottom: 20%;
left: 50%;
transform: translate(-50%);
}
#close:hover {
cursor: pointer;
}
.LOGO {
font-size: 4.5em;
}

<head>
<link rel="stylesheet" type="text/css" href="style.css">
<!--<script src="jquery-1.10.2.min.js"></script>-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="main.js"></script>
<title>A'S COFFEE</title>
</head>
<body>
<div id="wrapper">
<div id="MenuIcon">
<div id="MenuLine"></div>
</div>
<div id="MainMenu">
<div id="logo">
<h1 class="logo">A's Coffee</h1>
</div>
<ul>
<li>HOME
<div class="line"></div>
</li>
<li>MAKE AN ORDER
<div class="line"></div>
</li>
<li>VIEW ORDERS
<div class="line"></div>
</li>
</ul>
<div id="close">
<P>Click to leave</P>
</div>
</div>
<div id="centeralign">
<a class="button" id="btn1" href="place.html">Want to Place <br>an Order?</a><br>
<a class="button" id="btn2" href="#">View Orders?</a>
</div>
&#13;
任何帮助将不胜感激:)
答案 0 :(得分:1)
您可以在z-index
#MainMenu
#MainMenu {
height: 100vh;
width: 300px;
background-color: #181818;
-webkit-clip-path: polygon(0 0, 100% 0, 0% 100%, 0% 100%);
position: fixed;
top: 0;
left: -300px;
transition: all .5s ease-in-out;
z-index: 2;
}
工作代码段
$(document).ready(function() {
$("#MenuIcon").click(function() {
$("#MainMenu").css("left", "0px");
$("#MOVE").css("left", "300px");
function showMenu() {
$("#MainMenu").css("-webkit-clip-path", "polygon(0 0,100% 0,100% 100%,0% 100%)");
$("#MenuIcon").animate({
right: '-100'
}, 300);
}
setTimeout(showMenu, 100);
});
$("#close").click(function() {
$("#MainMenu").css("-webkit-clip-path", "polygon(0 0,0% 0,100% 100%,0% 100%)");
function hideMenu() {
$("#MainMenu").css("left", "-300px");
$("#MOVE").css("left", "0px")
$("#MenuIcon").animate({
right: '50'
}, 300);
}
setTimeout(hideMenu, 300);
function originalLayout() {
$("#MainMenu").css("-webkit-clip-path", "polygon(0 0,100% 0,0% 100%,0% 100%)");
}
setTimeout(originalLayout, 600);
});
});
body {
background-color: purple;
}
#MainMenu {
height: 100vh;
width: 300px;
background-color: #181818;
-webkit-clip-path: polygon(0 0, 100% 0, 0% 100%, 0% 100%);
position: fixed;
top: 0;
left: -300px;
transition: all .5s ease-in-out;
z-index: 2;
}
h1 {
color: #e5b78e;
font-family: Arial;
font-size: 100pt;
padding: 0px;
margin: 0px;
display: block;
}
.button {
display: inline-block;
background: transparent;
text-transform: uppercase;
font-weight: bold;
font-style: normal;
font-family: Arial;
font-size: 2em;
letter-spacing: 0.2em;
color: rgba(223, 190, 106, 0.7);
border-radius: 0;
padding: 18px 80px 20px;
transition: all 0.7s ease-out;
background: linear-gradient(270deg, rgba(223, 190, 106, 0.8), rgba(146, 111, 52, 0.8), rgba(34, 34, 34, 0), rgba(34, 34, 34, 0));
background-position: 1% 50%;
background-size: 300% 300%;
text-decoration: none;
margin: 0.625rem;
border: none;
border: 1px solid rgba(223, 190, 106, 0.3);
}
.button:hover {
color: #fff;
border: 1px solid rgba(223, 190, 106, 0);
color: $white;
background-position: 99% 50%;
}
#btn1 {
margin-top: 30px;
display: inline-block;
padding-left: 30px;
padding-right: 30px;
}
#btn2 {
margin-top: 30px;
display: inline-block;
padding-left: 47px;
padding-right: 47px;
}
.button:hover {
opacity: 1;
transition: opacity .2s ease-in;
}
#centeralign {
text-align: center;
top: 20em;
position: relative;
transition: all .5s ease-in-out;
}
br {
padding: 40px;
}
/* NAV */
#MenuIcon {
height: 25px;
width: 50px;
position: fixed;
top: 50;
right: 50;
}
#MenuIcon:hover {
cursor: pointer;
}
#MenuLine {
height: 4px;
width: 50px;
background-color: #e5b78e;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
transition: all .3s;
}
#MenuIcon:hover #MenuLine {
width: 40px;
}
#MenuLine::before {
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: 10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::before {
width: 50px;
}
#MenuLine::after {
content: '';
height: 4px;
width: 40px;
background-color: #e5b78e;
position: absolute;
margin-top: -10px;
transition: all .3s;
}
#MenuIcon:hover #MenuLine::after {
width: 50px;
}
ul {
list-style: none;
padding: 0px;
margin: 0px;
font-family: arial;
font-weight: bold;
color: white;
text-align: center;
position: absolute;
top: 55%;
left: 50%;
transform: translate(-50%, -50%);
}
ul li {
margin: 20px;
}
ul li:hover {
cursor: pointer;
}
.line {
height: 2px;
width: 150px;
background-color: white;
margin-top: 10px;
position: absolute;
left: 50%;
transform: translate(-50%);
transition: all .3s;
}
ul li:hover .line {
width: 180px;
}
#logo {
position: absolute;
top: 10%;
left: 50%;
transform: translate(-50%);
}
#close {
position: absolute;
bottom: 20%;
left: 50%;
transform: translate(-50%);
}
#close:hover {
cursor: pointer;
}
.LOGO {
font-size: 4.5em;
}
<head>
<link rel="stylesheet" type="text/css" href="style.css">
<!--<script src="jquery-1.10.2.min.js"></script>-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="main.js"></script>
<title>A'S COFFEE</title>
</head>
<body>
<div id="wrapper">
<div id="MenuIcon">
<div id="MenuLine"></div>
</div>
<div id="MainMenu">
<div id="logo">
<h1 class="logo">A's Coffee</h1>
</div>
<ul>
<li>HOME
<div class="line"></div>
</li>
<li>MAKE AN ORDER
<div class="line"></div>
</li>
<li>VIEW ORDERS
<div class="line"></div>
</li>
</ul>
<div id="close">
<P>Click to leave</P>
</div>
</div>
<div id="centeralign">
<a class="button" id="btn1" href="place.html">Want to Place <br>an Order?</a><br>
<a class="button" id="btn2" href="#">View Orders?</a>
</div>