为什么这个导航栏会出现这样的情况?[已关闭]

问题描述 投票:-2回答:1

我想有一个导航栏,有白色的文本链接,而不是它的下划线,但相反,它已经出现了一个div中的基本链接,所以一直没有工作,但我不知道缺少什么。

任何建议都将是apricated.I wanted to have a navigation bar that has white text links without underlined and instead it has appeared with basic links in a div so hasn't worked but I don't know what is missing.

<html>
<style>
.box3{
  padding:7px;
  background: black;
  font-family: arial;
  font-size:15px;
 }
 </style>
 
 <div class="box3">
  <a href="#home">Home</a>
  <a href="#about">About</a>
  <a href="#contact">Contact</a>
 </div>

</html>
  
html css navigationbar
1个回答
1
投票

你需要为你的链接添加样式,例如你可以添加

.box3 a {
  color: white;
  text-decoration: none;
}

这将把颜色改为白色,并删除下划线。

.box a { css } 将只针对box3 div内的a标签。

.box3 {
  padding: 7px;
  background: black;
  font-family: arial;
  font-size: 15px;
}

.box3 a {
  color: white;
  text-decoration: none;
}
<div class="box3">
  <a href="#home">Home</a>
  <a href="#about">About</a>
  <a href="#contact">Contact</a>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.