gpt4 book ai didi

html - 悬停时更改引导导航栏链接的颜色

转载 作者:行者123 更新时间:2023-11-28 19:23:55 25 4
gpt4 key购买 nike

我有一个 Bootstrap 导航栏,我想在悬停时更改导航栏中链接的颜色。我已经为它尝试过 CSS,但它不起作用。我不想更改代码,但在相同的标记类中我想添加效果。有些人使用列表作为导航栏,我不想这样做。

我尝试为每个标签中定义的类悬停添加相同的 CSS。

<!doctype html>
<html>
<head>
<title>Contact Us</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<link href="contact.css" type="text/css">
</head>

<body>
<div class="container-fullwidth">
<nav class="navbar navbar-expand-lg navbar-dark bg-success fixed-top">
<h1 class="navbar-brand"><strong>Digitian Hub</strong></h1>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#NewMenu" aria-expanded="false" aria-controls="NewMenu" aria-label="toggleNavigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="NewMenu">
<div class="navbar-nav">
<a class="nav-item nav-link" href="Rishabh.html"><strong>Home</strong></a>
<a class="nav-item nav-link services-link" href="#"><strong>Services</strong></a>
<a class="nav-item active nav-link contact-link" href="Contact Us.html"><strong>Contact Us</strong></a>
</div>
</div>
</nav>
</div>
</body>
</html>

当我将鼠标悬停在服务上时,我想在服务上显示绿色。

最佳答案

.services-link strong:hover {
color: green;
}
<!doctype html>
<html>

<head>
<title>Contact Us</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<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.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<link href="contact.css" type="text/css">
</head>

<body>
<div class="container-fullwidth">
<nav class="navbar navbar-expand-lg navbar-dark bg-success fixed-top">
<h1 class="navbar-brand"><strong>Digitian Hub</strong></h1>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#NewMenu" aria-expanded="false" aria-controls="NewMenu" aria-label="toggleNavigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="NewMenu">
<div class="navbar-nav">
<a class="nav-item nav-link" href="Rishabh.html"><strong>Home</strong></a>
<a class="nav-item nav-link services-link" href="#"><strong>Services</strong></a>
<a class="nav-item active nav-link contact-link" href="Contact Us.html"><strong>Contact Us</strong></a>
</div>
</div>
</nav>
</div>
</body>

</html>

关于html - 悬停时更改引导导航栏链接的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56747056/

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