【发布时间】:2018-07-12 20:31:07
【问题描述】:
我的所有列表项都有悬停效果,我的顶部列表项“推荐”上有活动悬停效果。我希望在将鼠标悬停在其他列表项上时停用“推荐”上的活动悬停效果。这样,一次只有一个悬停效果处于活动状态,但如果没有其他悬停效果,默认的“推荐”链接将始终处于活动状态。
我知道这可能需要一些 jquery?任何和所有的帮助将不胜感激。
这是我的代码,HTML:
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Comfortaa" rel="stylesheet">
</head>
<body>
<div class="wrapper">
<ul>
<li>
<a class="testimonials" href="#">
<h1>testimonials</h1>
<h2>We love our</h2>
<div class="selector"><img scr="img/logo.png"></img></div>
</a>
</li>
<li>
<a class="instructions" href="#">
<h1>instructions</h1>
<h2>For your information</h2>
</a>
</li>
<li>
<a class="Benefits" href="#">
<h1>benefits</h1>
<h2>A choice</h2>
</a>
</li>
<li>
<a class="Top-Recipe" href="#">
<h1>top</h1>
<h2>Recommendation</h2>
</a>
</li>
<li>
<a class="Affiliations" href="#">
<h1>affiliations</h1>
<h2>Valued Retailers</h2>
</a>
</li>
</ul>
</div>
</body>
</html>
CSS:
body
{
margin: 0;
padding: 0;
font-family: 'Comfortaa', cursive;
}
.wrapper
{
position: fixed;
width: 50%;
height: 100vh;
padding-left: 40px;
padding-right: 40px;
background: #fff;
}
.wrapper ul
{
position: absolute;
top: 20%;
left: 23%;
right: 10%;
}
.wrapper ul li
{
list-style: none;
margin-top: 10%;
}
.wrapper ul li a
{
text-decoration: none;
color: #011933;
}
.wrapper ul li a:hover
{
text-decoration: none;
}
.wrapper ul li a h1
{
font-size: 28px;
}
.wrapper ul li a h1:hover
{
font-size: 28px;
color: #8a6b0c;
}
.wrapper .testimonials
{
color: #8a6b0c;
}
.wrapper ul li a h2
{
font-size: 14px;
margin-left: 20px;
opacity: .6;
}
.wrapper ul li a h1, h2
{
width: 50%;
height: 60px;
padding: 0;
display: inline;
}
【问题讨论】:
标签: javascript jquery html css hover