简体   繁体   English

设置边距和填充 <input type='radio' /> 在CSS?

[英]Setting margin and padding for <input type='radio' /> in css?

I can't seem to get the CSS to modify my radio buttons. 我似乎无法获得CSS来修改单选按钮。 Their default settings aren't symmetrical so my layout looks a little ugly. 它们的默认设置不是对称的,因此我的布局看起来有些难看。 I am generating a bunch of these forms with javascript. 我正在用JavaScript生成大量此类表格。 I do not want to inject large amounts of inline style='margin:0px padding:0px' stuff but it's the only way I can get it to work. 我不想注入大量内联style='margin:0px padding:0px'东西,但这是我可以使其正常工作的唯一方法。

Using a CSS selector, you can probably do this: 使用CSS选择器,您可以执行以下操作:

input[type=radio] { margin: 0; padding: 0; }

Note however that older versions of IE don't support attribute selectors . 但是请注意,较旧版本的IE 不支持属性选择器 For those, you can do: 对于这些,您可以执行以下操作:

<div class="radios">
   ...input tags...
</div>

and

.radios input { margin: 0; padding: 0; }

to catch the oldies. 赶上老歌。 This would cut down the amount of presentational code while maintaining compatibility with ie6. 这样可以减少表示代码的数量,同时保持与ie6的兼容性。

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

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