简体   繁体   English

复选框:删除焦点上的正方形

[英]Checkbox: remove the square on focus

How can I remove the small square arround the radio button that gets displayed when the input gets focused? 当输入获得焦点时,如何删除显示的单选按钮周围的小方块?

在此处输入图片说明

I'm pretty sure this is a duplicate, but I don't know what the square is actually called and couldn't find what I'm looking for. 我很确定这是重复的,但我不知道该广场实际上叫什么,也找不到我想要的东西。

I tried autocomplete="off" on the input. 我在输入中尝试使用autocomplete="off" I played arround with jQuery's preventDefault but without success. 我与jQuery的preventDefault但是没有成功。

Update: Thanks for your responses. 更新:感谢您的回复。 If anyone comes accross this question, here is the effect of appearance attached (upper pic without appearance, the one below is with appearance) with Firefox: 如果有人遇到此问题,这是使用Firefox附加appearance的效果(上面的图片没有外观,下面的是有外观的):

在此处输入图片说明

Just in case someone comes to the same problem. 以防万一有人遇到同样的问题。

Update with Chrome / Safari, appearance removes the input 使用Chrome / Safari 更新appearance 删除输入

-webkit-appearance: none; would make the radio buttons disappear in Chrome and Safari. 会使单选按钮在Chrome和Safari中消失。 check jsfiddle.net/8uY6H (with Chrome) 检查jsfiddle.net/8uY6H(使用Chrome)

– noted by JFK 6 –肯尼迪国际机场第6号指出

Try this CSS since it is an outline: 尝试以下CSS,因为它是概述:

input[type="radio"]:focus {
    outline:none;
}

Try outline:0 property for the radio button on focus 尝试对焦点上的单选按钮的outline:0属性

input[type="radio"]:focus{
    outline:0;
}

You need to set: 您需要设置:

outline:none;

On the :focus state of the CSS class relating to the checkbox, or directly eg 在与复选框相关的CSS类的:focus状态上,或直接例如

input[type="radio"]:focus{
    outline:none;
}

The crucial part is setting outline 关键是设置outline

The CSS outline property is a shorthand property for setting one or more of the individual outline properties outline-style, outline-width and outline-color in a single rule. CSS轮廓属性是一种简写属性,用于在单个规则中设置一个或多个单个轮廓属性的轮廓样式,轮廓宽度和轮廓颜色。 In most cases the use of this shortcut is preferable and more convenient. 在大多数情况下,使用此快捷方式是可取的,并且更方便。

However, also setting appearance may help cross platform where different browsers render checkbox elements differently. 但是,设置appearance也可能有助于跨平台 ,在该平台上 ,不同的浏览器会以不同的方式呈现复选框元素。

As noted in the comments below though, this will cause the checkbox to not display in some circumstances- so you would need to produce a pure CSS solution. 如下面的注释中所述,在某些情况下,这将导致该复选框不显示-因此,您需要产生一个纯CSS解决方案。

The -moz-appearance CSS property is used in Gecko (Firefox) to display an element using a platform-native styling based on the operating system's theme. Gecko(Firefox)使用了-moz-appearance CSS属性,以基于操作系统主题的平台原生样式显示元素。

This property is frequently used in XUL stylesheets to design custom widgets with platform-appropriate styling. XUL样式表中经常使用此属性来设计具有平台适当样式的自定义窗口小部件。 It is also used in the XBL implementations of the widgets that ship with the Mozilla platform. Mozilla平台随附的小部件的XBL实现中也使用了它。

As simple as 就像

input[type="radio"] {
    outline: 0 none;
}

JSFIDDLE JSFIDDLE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM