html - 设置边框样式 :none; on my anchor tags but border shows up when I click on a link - why?

标签 html css onclick border

正如您从下面的示例中看到的那样,我有一个黑色背景和红色链接,以强调单击链接时在我的链接上显示虚线边框的问题。我加了border-style:none 但是好像没有什么效果。有没有其他方法可以消除单击链接时出现在链接周围的虚线边框?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html, body 
{
    height: 100%;
    margin: 0;
    padding: 0;
    font-weight:normal;
    font-size:12pt;
    font-family: Verdana, Arial, Helvetica, serif, sans-serif;
    background:black;
}

#linksouter
{
    margin: 0;
    padding: 0;
    border-style:solid;
    border-width:0px;
    position:absolute;
    top: 0px;
    left: 0px;
    width: 80px;
    text-align:left;
}
#linksinner
{
    margin: 80px 0 0 .5em;
    width:100%;
    display:inline;
    height:100%;
}
#linksinner a
{
    color:red;
    text-decoration: none;
    display:block;
    margin: 5px 0 0 0;
    border-style:none;
}
</style>
</head>

<body>
<div id="linksouter">
    <div id="linksinner">
    <a href="#">1</a>
    <a href="#">1</a>
    <a href="#">1</a>
    <a href="#">1</a>
    <a href="#">1</a>
    </div>
</div>

</body>
</html>

最佳答案

您看到的边框称为轮廓。您可以通过将此样式放入您的 a 规则中来摆脱它:

outline:none;

我个人总是将它定义为样式表顶部附近的一揽子 a 规则(我真的不喜欢轮廓,尽管我知道它们有用)

a { outline:none; }

希望对你有帮助

关于html - 设置边框样式 :none; on my anchor tags but border shows up when I click on a link - why?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1134929/

相关文章:

html - CSS-删除 hr 标签空间不起作用

jquery - 多类别下拉菜单

html - 图像位于无序列表项旁边的问题

css - Chrome 和 Safari 上 LI 元素周围的额外填充

html - 我的水平导航栏不会水平显示,为什么?

javascript - 为什么 vue 3 在第一次加载项目时导入所有页面的所有 js 文件

html - iOS Safari 上的字体溢出

php - 使用按钮 onclick 将 php while 循环中的值传递给 javascript

jquery ajax 按钮 onclick 事件不起作用

javascript - 使用scrapy,如何抓取带有onclick属性的复选框的页面?