去掉a标签点击时出现的边框

html+div+css 2736 0 2012-02-13

去掉a标签点击时出现的边框

只在a的标签里写上如下样式:

a{blr:expression(this.onFocus=this.blur()); outline:none;}

上一篇:网页256颜色色值(码)参考

下一篇:让并排的两个Div自适应高度(一样高)

讨论数量:2

天涯网魂 3 杠 5 星2013-04-23 11:14:21

使用jquery方法只需一句,非常简单,支持所有浏览器
$("a,input,button").focus(function(){this.blur()});

天涯网魂 3 杠 5 星2013-04-23 11:13:48

纯CSS去掉超链接或按钮点击时出现的虚线边框

<style type="text/css">

a,input,button{ outline:none; }
::-moz-focus-inner{border:0px;}

</style>

</head>

<body>

<a href="http://www.hilo8.com" target="_blank">hilo8.com</a>

<input type="button" value="hilo8.com"/>

<button>hilo8.com</button>

</body>

从以上代码可以看出,可以通过设置CSS属性outline解决。

FF存在bug,其中input,button标签通过私有属性::-moz-focus-inner特别处理

以上方法在IE6、IE7下无效。可使用 onfocus 属性解决,如下:

<a href="http://www.hilo8.com" target="_blank" onfocus="this.blur()">hilo8.com</a>

请先登录再发表讨论。 2024-04-25

天涯网魂
3 杠 5 星
TA 的文章
TA 的随言
TA 的资源链