a:链接和a:访问不起作用...?

问题描述 投票:0回答:2

CSS 中的 a:link 和 a:visited 代码不起作用。我不知道为什么,有点奇怪

而且,它实际上做了与我想要的相反的事情。访问之前,链接是紫色的,访问之后也是一样。

body {
  background-color: lightgoldenrodyellow;
  font-family: century gothic;
}
header {
  display: flex;
  justify-content: space-between;
  width: 100%;
  white-space: nowrap;
}
h1 {
  display: inline-block;
  font-size: 30px;
  text-decoration: underline;
}
nav {
  display: inline-block;
}
ul {
  color: black;
}
li {
  display: inline;
  font-size: 30px;
  margin-left: 10px;
  margin-right: 10px;
}
a:link {
  color: black;
}
a:visited {
  color: blueviolet;
}
footer {
  text-align: center;
  margin: 10px;
}
#image1,
#image2 {
  border-radius: 6px;
  display: block;
  margin: auto;
  margin-bottom: 80px;
  width: 70%;
}
p {
  text-align-last: center;
  font-family: helvetica, lucida grande, sans-serif;
  font-size: 30px;
}
<header>
  <nav>
    <ul>
      <li><a href="#">Home</a>
      </li>
      <li><a href="#">About</a>
      </li>
      <li><a href="#">Blog</a>
      </li>
      <li><a href="#">Event</a>
      </li>
      <li><a href="#">Gallery</a>
      </li>
      <li><a href="#">Contact</a>
      </li>
    </ul>
  </nav>
</header>

<p>Your Home Show Your Vision</p>

<img src="p.d.jpg" alt="Your Perspective" id="image1" />

<img src="e7179db2d394aab60672c37700e15612.jpg" alt="Your Perspective" id="image2" />



<footer>Copyright &copy 2017</footer>

html css anchor
2个回答
1
投票

visited 选择器匹配其 href 链接已访问过的所有元素。

您需要设置不同的

href
,例如

<nav>
  <ul>
    <li><a href="https://www.google.co.in/">Home</a></li>
    <li><a href="about.html">About</a></li>
    <li><a href="blog.html">Blog</a></li>
    <li><a href="event.html">Event</a></li>
    <li><a href="galery.html">Gallery</a></li>
    <li><a href="contact.html">Contact</a></li>
  </ul>
</nav>

body {
	background-color: lightgoldenrodyellow;
	font-family: century gothic;
}
header {
	display: flex;
	justify-content: space-between;
	width: 100%;
	white-space: nowrap;
}
h1 {
	display: inline-block;
	font-size: 30px;
	text-decoration: underline;
}
nav {
	display: inline-block;
}
nav ul {
	color: black;
}
nav ul li {
	display: inline;
	font-size: 30px;
	margin-left: 10px;
	margin-right: 10px;
}
nav ul li a {
	color:#000;
}
a:link {
	color: black;
}
nav ul li a:visited {
	color: blueviolet;
}
footer {
	text-align: center;
	margin: 10px;
}
#image1, #image2 {
	border-radius: 6px;
	display: block;
	margin: auto;
	margin-bottom: 80px;
	width: 70%;
}
p {
	text-align-last: center;
	font-family: helvetica, lucida grande, sans-serif;
	font-size: 30px;
}
<header>
  <nav>
    <ul>
      <li><a href="https://www.google.co.in/">Home</a></li>
      <li><a href="about.html">About</a></li>
      <li><a href="blog.html">Blog</a></li>
      <li><a href="event.html">Event</a></li>
      <li><a href="galery.html">Gallery</a></li>
      <li><a href="contact.html">Contact</a></li>
    </ul>
  </nav>
</header>


0
投票

更改

href
,因为它是之前或已经访问过的链接。您需要不同的
href

© www.soinside.com 2019 - 2024. All rights reserved.