CSS:如何使标签出现在收音机的右侧?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10022363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
CSS: how to make label appear right of the radio?
提问by StackOverflowNewbie
Say I have the following mark up:
假设我有以下标记:
<label for="name">Name:</label>
<input type="radio" name="name" id="name"/>
The order of the tags appear to be proper to me (in a semantic sense: label before the thing you're labeling). But I want to display this as radio button first, followed by the label. How can I do that in CSS?
标签的顺序对我来说似乎是合适的(在语义上:在你要标记的东西之前标记)。但我想首先将其显示为单选按钮,然后是标签。我怎样才能在 CSS 中做到这一点?
回答by rlemon
You don't need CSS. Wrap your input in a label and put the text last.
你不需要 CSS。将您的输入包裹在标签中并将文本放在最后。
<label><input type="radio" name="name" id="name"/>Name:</label>
Is that still semantic for you?
这对你来说仍然是语义吗?
Or you could try the float.
或者你可以试试浮动。
回答by valentinas
Tag order in this case doesn't matter. And even if it did, then it would be the other way around - first you would have to create the radio button, and then reference it in the label.
在这种情况下,标签顺序无关紧要。即使是这样,它也会反过来——首先你必须创建单选按钮,然后在标签中引用它。
To answer your question: just do it in the order you want to display it
回答您的问题:只需按照您要显示的顺序进行操作
<input type="radio" name="name" id="name"/>
<label for="name">Name:</label>
fiddle http://jsfiddle.net/Jm2JR/1/..
回答by sandeep
回答by Cassie Smith
<label for="name" style="float:right;">Name:</label>
回答by Invincible
try this:
尝试这个:
<label style="position:relative; left:100px;" for="name">Name:</label>
<input type="radio" name="name" id="name"/>
2nd approach is :
第二种方法是:
<input type="radio" name="name" id="name"/>
<label for="name">Name:</label>
回答by Rohit Azad
Hi you just define your input tag as like that
嗨,你只是像那样定义你的输入标签
<label>Name:
<input type="radio" name="name" id="name"/></label>
<br />
<label>
<input type="radio" name="name" id="name"/> Name
</label>
?
Live demo http://jsfiddle.net/rohitazad/bhBQn/1/