CSS remove default blue border

2019-02-02 21:56发布

I have a form with multiple buttons where I use a JavaScript to submit the second button when some one presses enter.

This works great but if I open this form in IE the first button gets a blue border that tells the user "this is the button that will be pressed when you press enter".

Is there any way to remove that with CSS without overriding the rest of the button's styling?

default button style

Example:

<button  onclick="javascript:alert('remove');">Remove name</button>

8条回答
Root(大扎)
2楼-- · 2019-02-02 22:11

Think this should work (only tested IE10 on PC) for the border:

button { outline: 0; }

Want to remove the background (needed on WebKit/Blink)?

Add:

background: none;

Need to get rid of the border (removes background on IE10 too):

border: 0;

查看更多
Melony?
3楼-- · 2019-02-02 22:14

Use this code:

button {
    border : 0px;
    -moz-border-radius:7px;
    -webkit-border-radius:7px;
     border-radius:7px;
}
查看更多
Deceive 欺骗
4楼-- · 2019-02-02 22:18

This may help you. Use following CSS properties:

input, 
input:active, 
input:focus {     
    outline: 0;     
    outline-style: none;     
    outline-width: 0; 
}
查看更多
干净又极端
5楼-- · 2019-02-02 22:18
button{border:none; border-radius:4px; -moz-border-radius:4px;}
查看更多
萌系小妹纸
6楼-- · 2019-02-02 22:24

Use this code:

button { border:0;}
查看更多
Luminary・发光体
7楼-- · 2019-02-02 22:25

Simply add border-radius to develop the button look:

-moz-border-radius:7px;
-webkit-border-radius:7px;
border-radius:7px;
查看更多
登录 后发表回答