我有一个带有多个按钮的表单,当有人按下回车键时,我使用 JavaScript 提交第二个按钮。
这很好用,但是如果我在 IE 中打开这个表单,第一个按钮会得到一个蓝色边框,告诉用户“这是当你按下 enter 时将按下的按钮”。
有什么方法可以在不覆盖按钮样式的其余部分的情况下使用 CSS 删除它?
例子:
<button onclick="javascript:alert('remove');">Remove name</button>
我有一个带有多个按钮的表单,当有人按下回车键时,我使用 JavaScript 提交第二个按钮。
这很好用,但是如果我在 IE 中打开这个表单,第一个按钮会得到一个蓝色边框,告诉用户“这是当你按下 enter 时将按下的按钮”。
有什么方法可以在不覆盖按钮样式的其余部分的情况下使用 CSS 删除它?
例子:
<button onclick="javascript:alert('remove');">Remove name</button>
认为这应该适用于边框(仅在 PC 上测试过 IE10):
button { outline: 0; }
想要移除背景(WebKit/Blink 需要)?
添加:
background: none;
需要去掉边框(在 IE10 上也去掉背景):
border: 0;
Use this code:
button { border:0;}
我的解决方案(几个月后)
button:focus {
outline: 0;
box-shadow: none;
}
使用此代码:
button {
border : 0px;
-moz-border-radius:7px;
-webkit-border-radius:7px;
border-radius:7px;
}
这可能会对您有所帮助。使用以下 CSS 属性:
input,
input:active,
input:focus {
outline: 0;
outline-style: none;
outline-width: 0;
}
#sideToggle:focus, #sideToggle:active{
outline: 0;
outline-style:none;
outline-width:0;
}
如果其他人访问该帖子,这解决了我的问题。我单独添加了自己的样式,因为它们确实不是问题的核心。
button{border:none; border-radius:4px; -moz-border-radius:4px;}
只需添加边框半径来开发按钮外观:
-moz-border-radius:7px;
-webkit-border-radius:7px;
border-radius:7px;