我有以下内容:
HTML
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<title>Result</title>
</head>
<body>
<div>
<a href= https://google.com>Google</a>
<a href= https://google.com>Google</a>
<a href= https://google.com>Google</a>
</div>
</body>
</html>
CSS
a:hover{
text-decoration: none
}
a:first-child{
color: #CDBE70
}
a:nth-child(3){
color: #FFC125
}
我刚开始学习 HTML,但遇到了问题。我上面显示的是 3 个指向 google 的链接,但它们都在同一行上。我希望每个链接都在一个新行上。我尝试使用 <p>
并将 CSS 代码中的所有 a 更改为 p,但它没有执行任何操作。
最佳答案
如果链接在语义上位于列表中,您也应该在标记中复制它:
<ul>
<li><a href="https://google.com">Google</a></li>
<li><a href="https://google.com">Google</a></li>
<li><a href="https://google.com">Google</a></li>
</ul>
如果你不想在链接前面有元素符号,你可以使用 CSS list-style-type: none;
在 ul
中删除它们或 li
。
关于html - 新行链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29840408/