gpt4 book ai didi

html - :hover only works on some elements 的 CSS

转载 作者:太空宇宙 更新时间:2023-11-04 14:05:49 24 4
gpt4 key购买 nike

我们有一个导航,旨在允许用户优化存档中的内容。因此他们可以在菜单中选择年份,然后它会展开以从子菜单中选择月份并相应地过滤结果。它在大多数情况下工作得很好,但在悬停时生效的样式似乎只适用于每个子菜单的上半部分。对于第一年,它在 1 月至 10 月工作,第二年从 1 月至 9 月工作,每增加一个子菜单就会减少一个月。似乎没有任何理由。有什么想法吗?

CSS:

nav {
font-family: Helvetica, Arial, "Lucida Grande", sans-serif;
line-height: 1.5;
/*margin: 50px auto;*/
position: absolute;
right: 40px;
width: 200px;
-webkit-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
-moz-box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

.menu-item {
background: #fff;
width: 200px;
}

.menu-item h4 a {
color: white;
display: block;
text-decoration: none;
width: 200px;
}

.menu-item h4 {
border-bottom: 1px solid rgba(0,0,0,0.3);
border-top: 1px solid rgba(255,255,255,0.2);
color: #fff;
font-size: 15px;
font-weight: 500;
padding: 7px 12px;
/*Gradient*/
background: #a90329; /* Old browsers */
background: -moz-linear-gradient(top, #a90329 0%, #8f0222 44%, #6d0019 100%); /* FF3.6 */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a90329), color-stop(44%,#8f0222), color-stop(100%,#6d0019)); /* Chrome,Safari4 */
background: -webkit-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Chrome10,Safari5.1 */
background: -o-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* Opera 11.10 */
background: -ms-linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* IE10 */
background: linear-gradient(top, #a90329 0%,#8f0222 44%,#6d0019 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a90329', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
}

.menu-item h4:hover {
background: #cc002c; /* Old browsers */
background: -moz-linear-gradient(top, #cc002c 0%, #6d0019 100%); /* FF3.6 */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#cc002c), color-stop(100%,#6d0019)); /* Chrome,Safari4 */
background: -webkit-linear-gradient(top, #cc002c 0%,#6d0019 100%); /* Chrome10,Safari5.1 */
background: -o-linear-gradient(top, #cc002c 0%,#6d0019 100%); /* Opera 11.10 */
background: -ms-linear-gradient(top, #cc002c 0%,#6d0019 100%); /* IE10 */
background: linear-gradient(top, #cc002c 0%,#6d0019 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#cc002c', endColorstr='#6d0019',GradientType=0 ); /* IE6-9 */
}

.alpha p {
font-size: 13px;
padding: 8px 12px;
color: #aaa;
}

.menu-item ul {
background: #fff;
font-size: 13px;
line-height: 30px;
list-style-type: none;
overflow: hidden;
padding: 0px;
}

.menu-item ul a {
margin-left: 20px;
text-decoration: none;
color: #aaa;
display: block;
width: 200px;
}

/*li Styles*/
.menu-item li {
border-bottom: 1px solid #eee;
}

.menu-item li:hover {
background: #eee;
}

.menu-item ul {
background: #fff;
font-size: 13px;
line-height: 30px;
height: 0px; /*Collapses the menu*/
list-style-type: none;
overflow: hidden;
padding: 0px;
}

.menu-item ul {
background: #fff;
font-size: 13px;
line-height: 30px;
height: 0px;
list-style-type: none;
overflow: hidden;
padding: 0px;
/*Animation*/
-webkit-transition: height 1s ease;
-moz-transition: height 1s ease;
-o-transition: height 1s ease;
-ms-transition: height 1s ease;
transition: height 1s ease;
}

.menu-item:hover ul {
height: 372px;
/*#endregion */
}

HTML:

<nav>
<h2>View posts from: </h2>
<div class="menu-item alpha">
<h4><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year">@DateTime.Now.Year</a></h4>
<ul>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=1">January</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=2">February</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=3">March</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=4">April</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=5">May</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=6">June</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=7">July</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=8">August</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=9">September</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=10">October</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=11">November</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.Year&filterMonth=12">December</a></li>
</ul>
</div>

<div class="menu-item">
<h4><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year">@DateTime.Now.AddYears(-1).Year</a></h4>
<ul>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=1">January</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=2">February</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=3">March</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=4">April</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=5">May</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=6">June</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=7">July</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=8">August</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=9">September</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=10">October</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=11">November</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-1).Year&filterMonth=12">December</a></li>
</ul>
</div>

<div class="menu-item">
<h4><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year">@DateTime.Now.AddYears(-2).Year</a></h4>
<ul>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=1">January</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=2">February</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=3">March</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=4">April</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=5">May</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=6">June</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=7">July</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=8">August</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=9">September</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=10">October</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=11">November</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-2).Year&filterMonth=12">December</a></li>
</ul>
</div>

<div class="menu-item">
<h4><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year">@DateTime.Now.AddYears(-3).Year</a></h4>
<ul>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=1">January</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=2">February</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=3">March</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=4">April</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=5">May</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=6">June</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=7">July</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=8">August</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=9">September</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=10">October</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=11">November</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-3).Year&filterMonth=12">December</a></li>
</ul>
</div>

<div class="menu-item">
<h4><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year">@DateTime.Now.AddYears(-4).Year</a></h4>
<ul>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=1">January</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=2">February</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=3">March</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=4">April</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=5">May</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=6">June</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=7">July</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=8">August</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=9">September</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=10">October</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=11">November</a></li>
<li><a href="JeffreysArchive.cshtml?filterYear=@DateTime.Now.AddYears(-4).Year&filterMonth=12">December</a></li>
</ul>
</div>

</nav>

最佳答案

JSFiddle

JSFIDDLE

我在这里看不到任何问题,它在这个 jsfiddle 中工作正常。 div block 之间可以有重叠,z-index 可以为您提供临时解决方案。

关于html - :hover only works on some elements 的 CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21123937/

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