为每个标签在表单中为CSS添加新行 [英] Make new lines in CSS in form for each label

查看:139
本文介绍了为每个标签在表单中为CSS添加新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有HTML代码

I have HTML code

<form id="answers">
blue
<input id="0" type="radio">
red
<input id="1" type="radio">
pink
<input id="2" type="radio">
<input type="submit">
</form>

我想让每个元素都在新行中。我不想使用< br> 之类的内容。在CSS文件中,我试过这样做: display:block 但没有任何变化。

and I want to have each element in the new line. I don't want to use stuff like <br>. In CSS file I tried do this: display: block but nothing's changed.

推荐答案

#answers input {display: block;}

这将使每个输入都在自己的行中。
如果您希望将每个输入的标签放在一行中,您应该做一些类似于

this will make every input in its own line. If you wish to have every input with its label together in a line you should do something like

<form id="answers">
    <label>blue <input id="0" type="radio"></label>
    <label>red <input id="1" type="radio"></label>
    <label>pink <input id="2" type="radio"></label>
    <input type="submit">
</form>

css:
#answers label {display:block;}

css: #answers label {display: block;}

http://jsfiddle.net/barakedry/y6p54vzg/

这篇关于为每个标签在表单中为CSS添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆