为什么我的标签和单选按钮不在同一行,我该怎么办?

这是我的表格:

<form name="submit" id="submit" action="#" method="post">
    <?php echo form_hidden('what', 'item-'.$identifier);?>

    <label for="one">First Item</label>
    <input type="radio" id="one" name="first_item" value="1" />

    <label for="two">Second Item</label>
    <input type="radio" id="two" name="first_item" value="2" />
    <input class="submit_form" name="submit" type="submit" value="Choose" tabindex="4" />
</form>

推荐答案

如果您使用HTML struct (我布局in this question),您可以简单地将标签和输入浮动到左侧,并调整填充/边距,直到排列整齐.

是的,您会想让您的单选按钮有一个旧IE的类名.根据我在上面链接的标记,如果在同一行上有all个这样的标记,应该是这样的:

fieldset {
      overflow: hidden
    }
    
    .some-class {
      float: left;
      clear: none;
    }
    
    label {
      float: left;
      clear: none;
      display: block;
      padding: 0px 1em 0px 8px;
    }
    
    input[type=radio],
    input.radio {
      float: left;
      clear: none;
      margin: 2px 0 0 2px;
    }
<fieldset>
      <div class="some-class">
        <input type="radio" class="radio" name="x" value="y" id="y" />
        <label for="y">Thing 1</label>
        <input type="radio" class="radio" name="x" value="z" id="z" />
        <label for="z">Thing 2</label>
      </div>
    </fieldset>

Css相关问答推荐

React呈现多个css文件

Tailwind css 和 Next.js 导航组件 z-index 不工作

如何让我的注册按钮在我的网站上像球一样 skip ?

和号 (&) 作为 SASS @mixin 中的变量

网格在行方向上的大小不正确

我在 ins 标签中有一个 img 标签,更改 ins 格式覆盖图像的视图

包含tailwind 中固定纵横比框的内容

在 css 中使用 first-of-type 效果太好了吗?

Bootstrap 类似乎没有任何作用

如何禁用亚像素渲染或强制浏览器将属性舍入到最近的像素?

Tailwind:如何设置网格的自动填充?

使用 MUI 动态绘制多个边框

如何隐藏锚文本而不隐藏锚?

导航栏中的 Bootstrap 3.0 按钮

下拉框中溢出文本的省略号

CSS:在图像周围创建白光

跨域 iframe 调整大小

CSS 否定伪类 :not() 用于父/祖先元素

从样式设置为 % 的元素获取宽度(以像素为单位)?

background-position-x (background-position-y) 是标准的 W3C CSS 属性吗?