我是CSS的新手,正在尝试创建一个悬停菜单。悬停时,下拉列表就非常完美了。在那之后,如果我将鼠标悬停在水下落的物品上,它会被洗白。
这是我的小提琴和代码。谁能帮我解决这个问题。
在下面的图片中,设计应该看起来像这样。
我尝试过右侧的三角形形状。但是,它也是白色洗净的。
有人可以帮助我解决此问题。
nav ul li a:hover, .dropdown:hover .dropbtn{
background-color: #EFF3F6;
}
nav ul li a {
position: relative;
}
nav ul li a:hover:after {
content: "";
display: block;
border-left: 10px solid transparent;
border-right: 10px solid transparent;
border-bottom: 10px solid #7B8B93;
position: absolute;
left: 35%;
bottom: 0px;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #7b8b93;
width: 100%;
left: 0;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
nav ul li .dropdown:hover .dropdown-content {
display: block;
}
.dropdown{
position: initial;
}
.nav-link:hover + .dropdown .dropdown-content{
display: block;
}
.one img:hover, .two img:hover, .three img:hover{
opacity: 0.3;
}
.open-source p {
border-top: 1px solid red;
padding: 0;
margin: 0;
}
.open-source p:last-child {
border-bottom: 1px solid red;
}
.open-source p a {
text-decoration: none;
color: #fff;
position: relative;
font-size: 30px;
width: 100%;
}
.open-source p:hover {
background: #fff;
border-left: 10px solid orange;
color: #111;
}
.open-source p:hover a:after {
content: "";
display: block;
border-top: 32px solid transparent;
border-left: 15px solid #fff;
border-bottom: 32px solid transparent;
position: absolute;
left: 100%;
bottom: 0px;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Logo</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">Solutions</a>
<div class="dropdown">
<div class="dropdown-content">
<div class="row">
<div class="col-lg-4 open-source">
<h3 class="ml-3">Open Source Solution Suites</h3>
<p class="ml-3"><a class="commerce" href="#">Dr.Commerce</a></p>
<p class="ml-3"><a class="universal" href="#">Universal Commerce</a></p>
<p class="ml-3"><a class="emmerging" href="#">Emmerging Techlogies</a></p>
</div>
<div class="col-lg-8 services">
<h3>Services & Technologies</h3>
<ul class="list-inline">
<li class="list-inline-item one">
<img src="./images/twitter-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item two">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item one two">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item three">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item one two">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item two">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item three">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item two">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item one three">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item three">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item three">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
<li class="list-inline-item two">
<img src="./images/instagram-xxl.png" width="60" height="67" alt="New York">
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js" integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k" crossorigin="anonymous"></script>
答案 0 :(得分:1)
您正在将p
元素的背景悬停设置为白色,这会导致您提到的“粉饰”效果。另外,您可能希望在悬停时更改a
文本的颜色,以便于阅读。
尝试以下类似方法作为起点。将鼠标悬停在background: #fff;
元素上时,请删除p
,并在悬停时为a
元素文本添加某种颜色。
.open-source p:hover {
border-left: 10px solid orange;
color: #111;
}
.open-source p:hover a {
color: #000;
}