我希望能夠運行導航頁面的左側(cè),子菜單出現(xiàn)在導航的右側(cè)/邊界(z索引,以便不把主要內(nèi)容推出的方式)。 有人有網(wǎng)站/代碼鏈接(codepen)或者代碼片段可以幫助嗎?我正在尋找一個onclick,而不是一個子菜單出現(xiàn)懸停事件... 第一個子菜單級別僅使用。下拉菜單:懸停。dropdown-content,而不是任何jquery,如果它需要jscript或jquery,就不會受到影響。多謝
<style>
* {margin: 0; padding: 0;}
html, body {height: 100%;}
body {background: #fff; padding: 0; margin: 0; font-family: Myriad-Pro, Arial, 'Varela Round', sans-serif; font-size: 16px;}
.quotation-window {display: flex; height: 100%}
.window-container {display: flex; flex-direction: row; flex-wrap: wrap; width: 100%;}
.header-one {display: flex; width: 100%; background-color: #dbdbdb; padding: 20px 10px;}
.header-two {display: flex; width: 100%; background-color: #afafaf; padding: 20px 10px;}
.content-container {display: flex; width: 100%; height: 100%}
.content-left {
display: flex;
background-color: #3f51b5;
color: #fff;
padding: 0;
flex-direction: row;
flex-wrap: wrap;
min-width: 80px;
align-content: flex-start;
height: 100%;
width: 9vw;
}
.content-right {display: flex; background-color: #6d6d6d; padding: 20px 10px; width: 95%;}
ul {
list-style-type: none;
background-color: #3f51b5;
color: #fff;
}
ul li ul.submenu {display: none;}
li a {
display: block;
color: #ffffff;
padding: 8px 16px;
text-decoration: none;
}
.dropdown-content li a {
display: flex;
color: #000000;
padding: 8px 0;
text-decoration: none;
}
li a:active {background-color: #3f51b5; color: white;}
/*li a:hover:not(.active) {background-color: #ffcc01; color: black;}*/
.dropdown {
position: relative;
display: inline-block;
width: 100%;
}
.dropdown li {height: 4vh; color: #000;}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
padding: 12px 16px;
z-index: 999;
left: 8.5vw;
top: 0;
height: 100vh;
flex-direction: row;
flex-wrap: wrap;
}
.dropdown-submenu {
position: relative;
display: inline-block;
width: 100%;
}
.dropdown-content-submenu {
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
padding: 12px 16px;
z-index: 999;
left: 11.1vw;
top: 0;
height: 100vh;
flex-direction: row;
flex-wrap: wrap;
}
.dropdown:hover .dropdown-content {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: flex-start;
}
.dropdown-submenu:hover .dropdown-content-submenu {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-content: flex-start;
}
@media screen and (max-width: 900px) and (min-width: 340px) {
.quotation-window {display: flex; height: 100%}
.content-container {
display: flex;
width: 100%;
flex-direction: row;
flex-wrap: wrap;
}
.content-left {
height: fit-content;
padding: 0;
width: 100%;
}
.content-right {
padding: 20px 0;
width: 100%;
height: 100%;
}
ul {display: inline-flex;}
.dropdown {display: inline-flex;}
.dropdown:hover .dropdown-content {
display: flex;
flex-direction: column;
flex-wrap: wrap;
width: 80%;
}
}
</style>
<section class="quotation-window">
<div class="window-container">
<div class="header-one">header 1</div>
<div class="header-two">header 2</div>
<div class="content-container">
<div class="content-left">
<ul class="dropdown">
<li><a href="#home" class="dropdown">New</a>
<ul class="dropdown-content">
<li><a href="#" class="dropdown-submenu">submenu navigation 1</a>
<ul class="dropdown-content-submenu">
<li>submenu navigation 1.1</li>
<li>submenu navigation 1.2</li>
<li>submenu navigation 1.3</li>
<li>submenu navigation 1.4</li>
<li>submenu navigation 1.5</li>
</ul>
</li>
<li>submenu navigation 2</li>
<li>submenu navigation 3</li>
<li>submenu navigation 4</li>
<li>submenu navigation 5</li>
</ul>
</li>
<li><a href="#news">Existing</a></li>
<li><a href="#contact">Inventory</a></li>
</ul>
</div>
<div class="content-right">right column content</div>
</div>
</div>
</section>
試試這個
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Classic's Blog</title>
<style>
nav ul {list-style-type: none; margin:0; padding:0; width: 200px; background-color: #f1f1f1; position: fixed;height: 100%}
nav ul li {min-width: 200px; font-size:14px;}
nav ul li a {display: block; color: #000; text-decoration: none; padding: 16px 0 16px 16px;}
ul li:hover > a {color: white; background-color: #555;}
.dropdown-content {
min-width: 150px;
display: none;
left: 200px;
float:left;
position: absolute;
font-size:14px;
margin-top: -48px;
}
.dropdown-content a {
background-color: #fbfbfb;
color: black;
text-decoration: none;
display: block;
text-align: left;
padding: 16px 0 16px 16px;
}
.dropdown:hover > .dropdown-content {
display: inline-block;
}
.main {
margin-left: 250px;
}
</style>
</head>
<body>
<header>
<nav>
<ul>
<li class="dropdown"><a href="">Menu item 1</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 11</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 111</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 1111</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 11111</a>
</li>
<li>
<a href="">Menu item 11112</a>
</li>
<li>
<a href="">Menu item 11113</a>
</li>
<li>
<a href="">Menu item 11114</a>
</li>
</ul>
</li>
<li class="dropdown"><a href="">Menu item 1112</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 11121</a>
</li>
<li>
<a href="">Menu item 11122</a>
</li>
<li>
<a href="">Menu item 11123</a>
</li>
<li>
<a href="">Menu item 11124</a>
</li>
</ul>
</li>
</ul>
</li>
<li>
<a href="">Menu item 112</a>
</li>
<li>
<a href="">Menu item 113</a>
</li>
</ul>
</li>
<li>
<a href="">Menu item 12</a>
</li>
<li>
<a href="">Menu item 13</a>
</li>
<li>
<a href="">Menu item 14</a>
</li>
</ul>
</li>
<li><a href="">Menu item 2</a></li>
<li class="dropdown"><a href="">Menu item 3</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 31</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 311</a>
<ul class="dropdown-content">
<li class="dropdown"><a href="">Menu item 3111</a>
<ul class="dropdown-content">
<li><a href="">Menu item 31111</a></li>
<li><a href="">Menu item 31112</a></li>
<li><a href="">Menu item 31113</a></li>
<li><a href="">Menu item 31114</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="">Menu item 312</a></li>
<li><a href="">Menu item 313</a></li>
<li><a href="">Menu item 314</a></li>
</ul>
</li>
<li><a href="">Menu item 32</a></li>
<li><a href="">Menu item 33</a></li>
<li><a href="">Menu item 34</a></li>
</ul>
</li>
<li><a href="">Menu item 4</a></li>
</ul>
</nav>
</header>
<div class="main">
<h2>Sidenav Example</h2>
<p>This sidenav is always shown.</p>
</div>
</body>
</html>
設(shè)法找到我需要的代碼。 如果有人對垂直左導航感興趣,就在這里 https://jsfiddle.net/alvaromenendez/9m60mx6r/7/
<style>
html, body {
margin:0;
padding:0;
height:100%;
}
* {box-sizing: border-box;}
.container {
height:100%;
}
a {
color:#fff;
text-decoration:none;
border-bottom:1px dotted #fff;
padding:0px 0px 20px 0px;
width:100%;
display:block;
height:100%;
}
li {
padding:20px 20px 0 20px;
width:100%;
color:#fff;
}
.container ul {height:100%;}
.container > ul {
width:250px;
background-color:#224490;
position:relative;
overflow:visible;
}
.container > ul > li {}
.container > ul > li:hover {background-color:#0f1e41;}
.container > ul > li > ul {
display:none;
position:absolute;
right:-250px;
top:0;
width:250px;
background-color:#18316a;
}
.container > ul > li:hover > ul {
display:block;
}
.container > ul > li > ul >li:hover {background-color:#0f1e41;}
.container > ul > li > ul > li > ul {
display:none;
position:absolute;
right:-250px;
top:0;
width:250px;
background-color:#112551;
}
.container > ul > li > ul > li:hover ul {
display:block;
}
.container > ul > li > ul > li > ul > li:hover {background-color:#0f1e41;}
.container > ul > li > ul > li ul li ul li {
border-bottom:1px dotted #fff;
padding:20px;
}
</style>
<div class="container">
<ul class="">
<li class="">
<a tabindex="-1" href="#">Client Advice</a>
<ul class="">
<li class=""><a tabindex="-1" href="#">Pre-advice</a></li>
<li class=""><a href="#">Strategy & Technical</a></li>
<li class=""><a href="#">Research</a></li>
<li class="">
<a href="#">APL & Products</a>
<ul class="parent">
<li >
<a href="#">
Approved Product List
</a>
<ul class="child">
<li >Platforms</li>
<li >Managed Funds</li>
<li >Wealth Protection</li>
<li >Listed Securities</li>
<li >Wealth Protection</li>
<li >Listed Securities</li>
<li >Listed Securities</li>
</ul>
</li>
<li ><a href="#">Model Portfolios</a></li>
<li ><a href="#">Non-approved Products</a></li>
</ul>
</li>
<li class=""><a href="#">Implementation</a></li>
<li class=""><a href="#">Review</a></li>
<li class=""><a href="#">Execution Only</a></li>
</ul>
</li>
<li ><a href="#">Personal Development</a></li>
<li ><a href="#">Practice</a></li>
<li ><a href="#">News</a></li>
</ul>
</div>
<script>
$('.child').hide(); //Hide children by default
$('.parent').children().click(function () {
event.preventDefault();
$(this).children('.child').slideToggle('slow');
$(this).find('span').toggle();
});
</script>