gpt4 book ai didi

悬停时的 HTML/CSS 菜单和激活的菜单不会显示

转载 作者:太空宇宙 更新时间:2023-11-04 09:42:50 25 4
gpt4 key购买 nike

我正在为我的网站构建一个菜单,但出于某种原因,当我将鼠标悬停在某个元素上时,“事件”不会触发该类被激活。事件类也不会显示

总结: 1.On_Hover 不起作用 2.Active 也不会

相关代码在这里

@font-face {font-family: Futura; src: url('FuturaOriginal.ttf');}
@font-face {font-family: FuturaLight; src: url('FuturaLight.ttf');}
@font-face {font-family: FuturaBold; src: url('FuturaBold.ttf');}
BODY {
font-family: FuturaLight;
background: white; color: #333;
align-content: top;
margin: 0;
padding: 0;
}
.margin {
margin-left: 300px;
margin-right: 300px;
}

#primary_nav_wrap
{
margin-top:100px;
text-align: center;
position: fixed;
width: 100%;
color: white;
border-bottom: 5px solid darkgreen;
background-color: #FFDE46;
}

#primary_nav_wrap ul
{
list-style:none;
position:relative;
display: inline-block;
margin:0;
padding:0;
color: darkgreen;
}

#primary_nav_wrap ul a
{
display:block;
color: white;
text-decoration:none;
font-weight:700;
font-size:20px;
line-height:32px;
padding:0 15px;
font-family: FuturaBold;
color: white;
background-color: darkgreen;

}


#primary_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0;
color: white;
}

#primary_nav_wrap ul li.current-menu-item
{
background-color: lawngreen;
color: white;
}

#primary_nav_wrap ul li:hover
{
background-color: black;
color: white;
}

#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background-color: white;
color: darkgreen;
padding:0;
}

#primary_nav_wrap ul ul li
{
float:none;
width:200px;
border: 1px solid #FFDE46;
color: White;
}

#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px;
color: White;

}

#primary_nav_wrap ul ul ul
{
top:0;
left:100%;
color: white;
}

#primary_nav_wrap ul li:hover > ul
{
display:block;
}

.spacer
{
width: 100%;
height: 110px;
}

.side
{
position: fixed;
width: 250px;
border-right-style: solid;
border-width: 5px;
height: 100%;
align-self: left;
float: left;
}

.main
{
width: 100%;
float: left;
}


H1 {
font-size: 60px;
margin-top: 0;
padding-bottom: 50px;
padding-top: 1px;
text-align: center;
list-style-type: none;
position: fixed;
width: 100%;
top: 0;
font-family: FuturaBold;
color: green;
background-color: #FFDE46;
}

/*Opmaak van je header2*/
H2 {
font-family: Futura;
font-size: 40px;
/*Kleur toevoegen*/
color: darkgreen;
/*Tekst centreren*/
text-align:center;
}

/*Opmaak header3*/
H3 {
font-family: Futura;
/*Kleur toevoegen*/
font-size:30px;
color: darkgreen
}
p.futura20{
font-family: Futura;
font-size: 16px
}

p.futura25{
font-family: Futura;
font-size: 20px
}

.spacer2
{
height: 10px;
}

#footer {
margin-bottom: 0px;
align-self: bottom;
height: 200px;
background-color: #FFDE46;
position: relative;
}

.scoutsgidsen {
height: 150px;
position: absolute;
left: 300px;
bottom: 20px;
}

.logo {
height: 150px;
position: absolute;
right: 300px;
bottom: 20px;
}

.avondlied {
font-family: Futura;
font-size: 18px;
text-align: center;
font-weight: 800;
}
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Scouts Permeke</TITLE>
<link rel="stylesheet" type="text/css" href="siteStyle.css">
</HEAD>
<BODY>
<H1>Scouts Permeke</H1>

<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item"><a href="scouts_permeke_site.html">Home</a></li>
<li><a href="scouts_news.html">Nieuws</a></li>
<li><a href="scouts_takken.html">Takken &#x25BC;</a>
<ul>
<li><a href="scouts_kapoenen.html">Kapoenen (6-8 jaar)</a></li>
<li><a href="scouts_kawellen.html">Kawellen (8-11 jaar)</a></li>
<li><a href="scouts_jonggivers.html">Jonggivers (11-14 jaar)</a></li>
<li><a href="scouts_givers.html">Givers (14-17 jaar)</a></li>
<li><a href="scouts_leiding.html">Jin, leiding en VT (+17 jaar)</a></li>
</ul>
</li>
<li><a href="scouts_activiteiten.html">Activiteiten &#x25BC;</a>
<ul>
<li><a href="scouts_kapoenena.html">Kapoenen</a></li>
<li><a href="scouts_kawellena.html">Kawellen</a></li>
<li><a href="scouts_jonggiversa.html">Jonggivers</a></li>
<li><a href="scouts_giversa.html">Givers</a></li>
</ul>
</li>
<li><a href="#">Praktisch &#x25BC;</a>
<ul>
<li><a href="scouts_taf&toetje.html">Taf & Toetje</a></li>
<li><a href="scouts_papierwerk.html">Papierwerk</a></li>
<li><a href="scouts_uniform.html">Uniform</a></li>
<li><a href="scouts_technieken.html">Technieken</a></li>
<li><a href="scouts_jaarthema.html">Jaarthema</a></li>
<li><a href="scouts_rituelen.html">Rituelen</a></li>
</ul>
</li>
<li><a href="scouts_afspraken.html">Algemeen</a></li>
<li><a href="scouts_over.html">Over</a></li>
<li><a href="scouts_fotos.html">Foto's</a></li>
<li><a href="scouts_inschrijven.html">Inschrijven</a></li>
<li><a href="scouts_verhuur.html">Verhuur</a></li>
<li><a href="scouts_contact.htmlv">Contact</a></li>
</ul>
</nav>

<div class="spacer">
&nbsp;
</div>

<img src="groepsfoto.jpg" width="100%"" >

<div style="font-family: Futura">
<H2>Welkom op onze vernieuwde site!</H2>
<H2>Kijk gerust even rond.</H2>
</div>
<div class="spacer2"></div>
</div>
<div id="footer">
<img src="logo_Scouts_en_Gidsen_Vlaanderen.png" class="scoutsgidsen"/>
<img src="logo.png" class="logo"/>
</div>
</BODY>
</HTML>

最佳答案

您正在将悬停规则应用于 li,但它被 a 元素覆盖,因此背景颜色的变化将不可见。所以最好将悬停规则应用于 a 元素:

#primary_nav_wrap ul li a:hover 而不是 #primary_nav_wrap ul li:hover

.current-menu-item 类似(我想这就是你所说的“事件类”的意思:

#primary_nav_wrap ul li.current-menu-item a
{
background-color: lawngreen;
color: white;
}

@font-face {font-family: Futura; src: url('FuturaOriginal.ttf');}
@font-face {font-family: FuturaLight; src: url('FuturaLight.ttf');}
@font-face {font-family: FuturaBold; src: url('FuturaBold.ttf');}
BODY {
font-family: FuturaLight;
background: white; color: #333;
align-content: top;
margin: 0;
padding: 0;
}
.margin {
margin-left: 300px;
margin-right: 300px;
}

#primary_nav_wrap
{
margin-top:100px;
text-align: center;
position: fixed;
width: 100%;
color: white;
border-bottom: 5px solid darkgreen;
background-color: #FFDE46;
}

#primary_nav_wrap ul
{
list-style:none;
position:relative;
display: inline-block;
margin:0;
padding:0;
color: darkgreen;
}

#primary_nav_wrap ul a
{
display:block;
color: white;
text-decoration:none;
font-weight:700;
font-size:20px;
line-height:32px;
padding:0 15px;
font-family: FuturaBold;
color: white;
background-color: darkgreen;

}


#primary_nav_wrap ul li
{
position:relative;
float:left;
margin:0;
padding:0;
color: white;
}

#primary_nav_wrap ul li.current-menu-item a
{
background-color: lawngreen;
color: white;
}
#primary_nav_wrap ul li a:hover
{
background-color: black;
color: white;
}

#primary_nav_wrap ul ul
{
display:none;
position:absolute;
top:100%;
left:0;
background-color: white;
color: darkgreen;
padding:0;
}

#primary_nav_wrap ul ul li
{
float:none;
width:200px;
border: 1px solid #FFDE46;
color: White;
}

#primary_nav_wrap ul ul a
{
line-height:120%;
padding:10px 15px;
color: White;

}

#primary_nav_wrap ul ul ul
{
top:0;
left:100%;
color: white;
}

#primary_nav_wrap ul li:hover > ul
{
display:block;
}

.spacer
{
width: 100%;
height: 110px;
}

.side
{
position: fixed;
width: 250px;
border-right-style: solid;
border-width: 5px;
height: 100%;
align-self: left;
float: left;
}

.main
{
width: 100%;
float: left;
}


H1 {
font-size: 60px;
margin-top: 0;
padding-bottom: 50px;
padding-top: 1px;
text-align: center;
list-style-type: none;
position: fixed;
width: 100%;
top: 0;
font-family: FuturaBold;
color: green;
background-color: #FFDE46;
}

/*Opmaak van je header2*/
H2 {
font-family: Futura;
font-size: 40px;
/*Kleur toevoegen*/
color: darkgreen;
/*Tekst centreren*/
text-align:center;
}

/*Opmaak header3*/
H3 {
font-family: Futura;
/*Kleur toevoegen*/
font-size:30px;
color: darkgreen
}
p.futura20{
font-family: Futura;
font-size: 16px
}

p.futura25{
font-family: Futura;
font-size: 20px
}

.spacer2
{
height: 10px;
}

#footer {
margin-bottom: 0px;
align-self: bottom;
height: 200px;
background-color: #FFDE46;
position: relative;
}

.scoutsgidsen {
height: 150px;
position: absolute;
left: 300px;
bottom: 20px;
}

.logo {
height: 150px;
position: absolute;
right: 300px;
bottom: 20px;
}

.avondlied {
font-family: Futura;
font-size: 18px;
text-align: center;
font-weight: 800;
}
<!DOCTYPE HTML>
<HTML>
<HEAD>
<TITLE>Scouts Permeke</TITLE>
<link rel="stylesheet" type="text/css" href="siteStyle.css">
</HEAD>
<BODY>
<H1>Scouts Permeke</H1>

<nav id="primary_nav_wrap">
<ul>
<li class="current-menu-item"><a href="scouts_permeke_site.html">Home</a></li>
<li><a href="scouts_news.html">Nieuws</a></li>
<li><a href="scouts_takken.html">Takken &#x25BC;</a>
<ul>
<li><a href="scouts_kapoenen.html">Kapoenen (6-8 jaar)</a></li>
<li><a href="scouts_kawellen.html">Kawellen (8-11 jaar)</a></li>
<li><a href="scouts_jonggivers.html">Jonggivers (11-14 jaar)</a></li>
<li><a href="scouts_givers.html">Givers (14-17 jaar)</a></li>
<li><a href="scouts_leiding.html">Jin, leiding en VT (+17 jaar)</a></li>
</ul>
</li>
<li><a href="scouts_activiteiten.html">Activiteiten &#x25BC;</a>
<ul>
<li><a href="scouts_kapoenena.html">Kapoenen</a></li>
<li><a href="scouts_kawellena.html">Kawellen</a></li>
<li><a href="scouts_jonggiversa.html">Jonggivers</a></li>
<li><a href="scouts_giversa.html">Givers</a></li>
</ul>
</li>
<li><a href="#">Praktisch &#x25BC;</a>
<ul>
<li><a href="scouts_taf&toetje.html">Taf & Toetje</a></li>
<li><a href="scouts_papierwerk.html">Papierwerk</a></li>
<li><a href="scouts_uniform.html">Uniform</a></li>
<li><a href="scouts_technieken.html">Technieken</a></li>
<li><a href="scouts_jaarthema.html">Jaarthema</a></li>
<li><a href="scouts_rituelen.html">Rituelen</a></li>
</ul>
</li>
<li><a href="scouts_afspraken.html">Algemeen</a></li>
<li><a href="scouts_over.html">Over</a></li>
<li><a href="scouts_fotos.html">Foto's</a></li>
<li><a href="scouts_inschrijven.html">Inschrijven</a></li>
<li><a href="scouts_verhuur.html">Verhuur</a></li>
<li><a href="scouts_contact.htmlv">Contact</a></li>
</ul>
</nav>

<div class="spacer">
&nbsp;
</div>

<img src="groepsfoto.jpg" width="100%"" >

<div style="font-family: Futura">
<H2>Welkom op onze vernieuwde site!</H2>
<H2>Kijk gerust even rond.</H2>
</div>
<div class="spacer2"></div>
</div>
<div id="footer">
<img src="logo_Scouts_en_Gidsen_Vlaanderen.png" class="scoutsgidsen"/>
<img src="logo.png" class="logo"/>
</div>
</BODY>
</HTML>

关于悬停时的 HTML/CSS 菜单和激活的菜单不会显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39747184/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com