最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Setting margin and padding for <input type='radio' > in css? - Stack Overflow

programmeradmin3浏览0评论

I can't seem to get the CSS to modify my radio buttons. Their default settings aren't symmetrical so my layout looks a little ugly. I am generating a bunch of these forms with 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.

I can't seem to get the CSS to modify my radio buttons. Their default settings aren't symmetrical so my layout looks a little ugly. I am generating a bunch of these forms with 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.

Share Improve this question asked Sep 25, 2011 at 2:09 Steven LuSteven Lu 43.6k63 gold badges219 silver badges382 bronze badges 2
  • Show some code or an example. If you can get what you want with inline style attributes, you should be able to do it with a stylesheet. – John Flatness Commented Sep 25, 2011 at 2:15
  • I knew somebody would know the answer without any pictures :-) – Steven Lu Commented Sep 25, 2011 at 2:17
Add a ment  | 

1 Answer 1

Reset to default 4

Using a CSS selector, you can probably do this:

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

Note however that older versions of IE don't support attribute selectors. 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 patibility with ie6.

发布评论

评论列表(0)

  1. 暂无评论