工作正常移動,但在全屏模式,因爲該選項消失我不能選擇懸停下拉選項不能得到這個響應菜單上班X(
我的代碼:
$('.handle').on('click', function(){
$('nav ul').toggleClass('showing');
});
body {
\t margin: 0;
\t padding: 0;
\t font-family: sans-serif;
}
.toggle,
[id^=drop] {
\t display: none;
}
/* Giving a background-color to the nav container. */
nav {
\t margin:0;
\t padding: 0;
\t background-color: #254441;
}
#logo {
\t display: block;
\t padding: 0 30px;
\t float: left;
\t font-size:20px;
\t line-height: 60px;
}
/* Since we'll have the "ul li" "float:left"
* we need to add a clear after the container. */
nav:after {
\t content:"";
\t display:table;
\t clear:both;
}
/* Removing padding, margin and "list-style" from the "ul",
* and adding "position:reltive" */
nav ul {
\t float: right;
\t padding:0;
\t margin:0;
\t list-style: none;
\t position: relative;
\t }
\t
/* Positioning the navigation items inline */
nav ul li {
\t margin: 0px;
\t display:inline-block;
\t float: left;
\t background-color: #254441;
\t }
/* Styling the links */
nav a {
\t display:block;
\t padding:14px 20px; \t
\t color:#FFF;
\t font-size:17px;
\t text-decoration:none;
}
nav ul li ul li:hover { background: #000000; }
/* Background color change on Hover */
nav a:hover {
\t background-color: #000000;
}
/* Hide Dropdowns by Default
* and giving it a position of absolute */
nav ul ul {
\t display: none;
\t position: absolute;
\t /* has to be the same number as the "line-height" of "nav a" */
\t top: 60px;
}
\t
/* Display Dropdowns on Hover */
nav ul li:hover > ul {
\t display:inherit;
}
\t
/* Fisrt Tier Dropdown */
nav ul ul li {
\t width:170px;
\t float:none;
\t display:list-item;
\t position: relative;
}
/* Second, Third and more Tiers \t
* We move the 2nd and 3rd etc tier dropdowns to the left
* by the amount of the width of the first tier.
*/
nav ul ul ul li {
\t position: relative;
\t top:-60px;
\t /* has to be the same number as the "width" of "nav ul ul li" */
\t left:170px;
}
\t
/* Change ' +' in order to change the Dropdown symbol */
li > a:after { content: ' +'; }
li > a:only-child:after { content: ''; }
/* Media Queries
--------------------------------------------- */
@media all and (max-width : 768px) {
\t #logo {
\t \t display: block;
\t \t padding: 0;
\t \t width: 100%;
\t \t text-align: center;
\t \t float: none;
\t }
\t nav {
\t \t margin: 0;
\t }
\t /* Hide the navigation menu by default */
\t /* Also hide the */
\t .toggle + a,
\t .menu {
\t \t display: none;
\t }
\t /* Stylinf the toggle lable */
\t .toggle {
\t \t display: block;
\t \t background-color: #254441;
\t \t padding:14px 20px; \t
\t \t color:#FFF;
\t \t font-size:17px;
\t \t text-decoration:none;
\t \t border:none;
\t }
\t .toggle:hover {
\t \t background-color: #000000;
\t }
\t /* Display Dropdown when clicked on Parent Lable */
\t [id^=drop]:checked + ul {
\t \t display: block;
\t }
\t /* Change menu item's width to 100% */
\t nav ul li {
\t \t display: block;
\t \t width: 100%;
\t \t }
\t nav ul ul .toggle,
\t nav ul ul a {
\t \t padding: 0 40px;
\t }
\t nav ul ul ul a {
\t \t padding: 0 80px;
\t }
\t nav a:hover,
\t nav ul ul ul a {
\t \t background-color: #000000;
\t }
\t nav ul li ul li .toggle,
\t nav ul ul a,
nav ul ul ul a{
\t \t padding:14px 20px; \t
\t \t color:#FFF;
\t \t font-size:17px;
\t }
\t nav ul li ul li .toggle,
\t nav ul ul a {
\t \t background-color: #212121;
\t }
\t /* Hide Dropdowns by Default */
\t nav ul ul {
\t \t float: none;
\t \t position:static;
\t \t color: #ffffff;
\t \t /* has to be the same number as the "line-height" of "nav a" */
\t }
\t \t
\t /* Hide menus on hover */
\t nav ul ul li:hover > ul,
\t nav ul li:hover > ul {
\t \t display: none;
\t }
\t \t
\t /* Fisrt Tier Dropdown */
\t nav ul ul li {
\t \t display: block;
\t \t width: 100%;
\t }
\t nav ul ul ul li {
\t \t position: static;
\t \t /* has to be the same number as the "width" of "nav ul ul li" */
\t }
}
@media all and (max-width : 330px) {
\t nav ul li {
\t \t display:block;
\t \t width: 94%;
\t }
}
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<body>
<nav>
<div id="logo">Your Logo here</div>
<label for="drop" class="toggle">Menu</label>
<input type="checkbox" id="drop" />
<ul class="menu">
<li><a href="#">Home</a></li>
<li>
<!-- First Tier Drop Down -->
<label for="drop-1" class="toggle">WordPress +</label>
<a href="#">WordPress</a>
<input type="checkbox" id="drop-1"/>
<ul>
<li><a href="#">Themes and stuff</a></li>
<li><a href="#">Plugins</a></li>
<li><a href="#">Tutorials</a></li>
</ul>
</li>
<li>
<!-- First Tier Drop Down -->
<label for="drop-2" class="toggle">Web Design +</label>
<a href="#">Web Design</a>
<input type="checkbox" id="drop-2"/>
<ul>
<li><a href="#">Resources</a></li>
<li><a href="#">Links</a></li>
<li>
<!-- Second Tier Drop Down -->
<label for="drop-3" class="toggle">Tutorials +</label>
<a href="#">Tutorials</a>
<input type="checkbox" id="drop-3"/>
<ul>
<li><a href="#">HTML/CSS</a></li>
<li><a href="#">jQuery</a></li>
<li><a href="#">Other</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#">Graphic Design</a></li>
<li><a href="#">Inspiration</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">About</a></li>
</ul>
</nav>
這裏是一個小提琴,所以你可以看到我說的傢伙:
http://jsfiddle.net/p1mrtuex/9/
請幫忙!
我改變了這一點,但仍然無法選擇較低的下拉選項中,不知道什麼可能會導致此。 – gabogabans
嘗試了一個比40px更低的數字?嘗試零開始 – Syfer
嘗試頂部:0px和頂部:100%,仍然沒有。在這裏有些不可思議的東西,就像下拉菜單不想被選中一樣 – gabogabans