我遇到了一个小问题,当我将鼠标放在按钮的最上方时,我可以单击它,但是当鼠标稍微向下时,出现下拉菜单,并且我无法再单击按钮: 这是代码的代码笔:https://codepen.io/amrouhab/pen/jObXxOy 这是我的代码:
<body>
<div id="header_bar">
<div id="header_bar_text" class="gpd-text">Syndicat Constructif, Partenaire du Dialogue Social
</div>
</div>
<nav>
<div href="#default" id="logo"><img src="logo_header.png"></div>
<label for="drop" class="toggle">Menu</label>
<input type="checkbox" id="drop" />
<ul class="menu">
<li><a href="#">Accueil</a></li>
<li>
<label for="drop-1" class="toggle">Connaitre la CFTC +</label>
<a href="#">Connaitre la CFTC</a>
<input type="checkbox" id="drop-1" />
<ul>
<li><a href="#!">Histoire</a></li>
<li><a href="#!">Valeurs</a></li>
<li><a href="#!">Identité</a></li>
</ul>
</li>
<li>
<label for="drop-1" class="toggle">Syndicat CFTC-FPT 34 +</label>
<a href="#">Syndicat CFTC-FPT 34</a>
<input type="checkbox" id="drop-2" />
<ul>
<li><a href="#!">Organisation</a></li>
<li><a href="#!">Accueil</a></li>
<li><a href="#!">Rôle et définition</a></li>
<!-- <li>
SECOND TIER DROP
<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>
<label for="drop-1" class="toggle">Vie Professionnelle +</label>
<a href="action.php">Vie Professionnelle</a>
<input type="checkbox" id="drop-1" />
<ul>
<li><a href="#!">Formation</a></li>
<li><a href="#!">Statut</a></li>
<li><a href="#!">Carrière</a></li>
<li><a href="#!">Temps de Travail</a></li>
<li><a href="#!">Congés</a></li>
</ul>
</li>
<li>
<label for="drop-1" class="toggle">Vie Pratique +</label>
<a href="#">Vie Pratique</a>
<input type="checkbox" id="drop-1" />
<ul>
<li><a href="#!">Action Logement</a></li>
<li><a href="#!">Pensions Alimentaires impayées</a></li>
<li><a href="#!">Prime d'activité</a></li>
<li><a href="#!">Apprentissage</a></li>
</ul>
</li>
<li>
<label for="drop-1" class="toggle">Activités +</label>
<a href="#">Activités</a>
<input type="checkbox" id="drop-1" />
<ul>
<li><a href="#!">Actualités</a></li>
<li><a href="#!">Presse</a></li>
</ul>
</li>
<li>
<label for="drop-1" class="toggle">Adhésion +</label>
<a href="#">Adhésion</a>
<input type="checkbox" id="drop-1" />
<ul>
<li><a href="#!">Les + adhérents</a></li>
<li><a href="#!">Espace adhérents</a></li>
<li><a href="#!">Nous rejoindre</a></li>
</ul>
</li>
<li>
<label for="drop-1" class="toggle">Coordonnées +</label>
<a href="#">Coordonnées</a>
<input type="checkbox" id="drop-1" />
<ul>
<li><a href="#!">Syndicat CFTC-FPT 34</a></li>
<li><a href="#!">UD34</a></li>
<li><a href="#!">Fédération CFTC FPT</a></li>
</ul>
</li>
</ul>
</nav>
</body>
还有我的CSS:
/* CSS Document */
@font-face {
font-family: "oswald";
src: url("fonts\oswald.regular.ttf");
font-family: "lato";
src: url("fonts\Lato-Regular.ttf");
font-family: "playfairdisplay";
src: url("fonts\PlayfairDisplaySC-Regular.otf");
}
body {
background: #e9dfdf;
/* font-size: 30px; */
/* line-height: 32px; */
color: #ffffff;
margin: 0;
/* padding: 0; */
word-wrap: break-word !important;
font-family: oswald;
}
/* h1 {
font-size: 60px;
text-align: center;
color: #FFF;
}
h3 {
font-size: 30px;
line-height: 34px;
text-align: center;
color: #FFF;
}
h3 a {
color: #FFF;
} */
a {
color: #FFF;
}
/* h1 {
margin-top: 100px;
text-align: center;
font-size: 60px;
line-height: 70px;
font-family: 'Bree Serif', 'serif';
} */
#container {
margin: 0 auto;
max-width: 890px;
}
/* p {
text-align: center;
} */
.toggle,
[id^=drop] {
display: none;
}
/* Giving a background-color to the nav container. */
nav {
margin: 0px;
padding: 15px 10px 10px 10px;
background-color: #01B2C0;
position: relative;
}
#logo {
display: block;
padding: 0px 30px 0px 15px;
float: left;
/* font-size: 20px; */
/* line-height: 60px; */
}
/* Since we'll have the "ul li" "float:left"
* we need to add a clear after the container. */
nav:after {
content: "";
display: table;
clear: both;
}
/* Removing padding, margin and "list-style" from the "ul",
* and adding "position:reltive" */
nav ul {
float: none;
padding: 0;
margin: 0;
list-style: none;
position: absolute;
/* bottom: 0; */
left: 137px;
padding: 44px 37px 35px 120px;
}
/* Positioning the navigation items inline */
nav ul li {
margin: 0px;
display: inline-block;
background-color: #01B2C0;
position: relative;
padding: 0px 5px 0px 5px;
}
/* Styling the links */
nav a {
display: block;
padding: 10px 15px;
color: #000000;
font-size: 24px;
text-decoration: none;
position: relative;
}
nav ul li ul li:hover {
border: solid 1px;
background: #07858f;
}
/* Background color change on Hover */
nav a:hover {
background-color: #07858f;
}
/* Hide Dropdowns by Default
* and giving it a position of absolute */
nav ul ul {
display: none;
position: absolute;
/* has to be the same number as the "line-height" of "nav a" */
top: 15px;
left: -100px;
}
/* Display Dropdowns on Hover */
nav ul li:hover>ul {
display: inherit;
}
/* Fisrt Tier Dropdown */
nav ul ul li {
width: 170px;
float: none;
display: list-item;
position: relative;
}
/* Second, Third and more Tiers
* 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 {
position: relative;
top: -60px;
/* has to be the same number as the "width" of "nav ul ul li" */
left: 170px;
}
/* Change ' +' in order to change the Dropdown symbol */
li>a:after {
content: ' +';
}
li>a:only-child:after {
content: '';
}
#header_bar{
padding:5px 0px 0px 0px;
min-height:50px;
background-color:#01B2C0;
margin: auto;
color: #000000;
font-size: 25px;
}
#header_bar_text{
background-color:#01B2C0;
margin: 0px 0px 0px 0px;
text-align: center;
}
/* Media Queries
--------------------------------------------- */
@media all and (max-width : 768px) {
#logo {
display: block;
padding: 0;
width: 100%;
text-align: center;
float: none;
}
nav {
margin: 0;
}
/* Hide the navigation menu by default */
/* Also hide the */
.toggle+a,
.menu {
display: none;
}
/* Stylinf the toggle lable */
.toggle {
display: block;
background-color: #254441;
padding: 14px 20px;
color: #FFF;
font-size: 17px;
text-decoration: none;
border: none;
}
.toggle:hover {
background-color: #000000;
}
/* Display Dropdown when clicked on Parent Lable */
[id^=drop]:checked+ul {
display: block;
}
/* Change menu item's width to 100% */
nav ul li {
display: block;
width: 100%;
}
nav ul ul .toggle,
nav ul ul a {
padding: 0 40px;
}
nav ul ul ul a {
padding: 0 80px;
}
nav a:hover,
nav ul ul ul a {
background-color: #000000;
}
nav ul li ul li .toggle,
nav ul ul a,
nav ul ul ul a {
padding: 14px 20px;
color: #FFF;
font-size: 17px;
}
nav ul li ul li .toggle,
nav ul ul a {
background-color: #212121;
}
/* Hide Dropdowns by Default */
nav ul ul {
float: none;
position: static;
color: #ffffff;
/* has to be the same number as the "line-height" of "nav a" */
}
/* Hide menus on hover */
nav ul ul li:hover>ul,
nav ul li:hover>ul {
display: none;
}
/* Fisrt Tier Dropdown */
nav ul ul li {
display: block;
width: 100%;
}
nav ul ul ul li {
position: static;
/* has to be the same number as the "width" of "nav ul ul li" */
}
}
@media all and (max-width : 330px) {
nav ul li {
display: block;
width: 94%;
}
}
<nav>
就是这样,谢谢您的帮助!