对齐复选框旁边的文本

Tim*_*ych 10 html css

简单的问题,毫无疑问是一个简单的解决方案 - 尽管在搜索SO和谷歌一段时间后,我仍然很难找到它.

我所要做的就是拿一段文字" 我对增强的列表或高级档案感兴趣,(我们团队的一名成员将及时回复更多信息) "并将其与支票右侧对齐框(文字左对齐),但不像现在一样环绕它.

这是我的JSFiddle

代码(使用PureCSS进行样式设计):

<form class="pure-form pure-form-aligned">
                    <fieldset>
                        <div class="pure-control-group">
                            <label for="name">Product Name</label>
                            <input id="name" type="text" placeholder="Username">
                        </div>

                        <div class="pure-control-group">
                            <label for="password">Contact Name</label>
                            <input id="password" type="text" placeholder="Password">
                        </div>

                        <div class="pure-control-group">
                            <label for="email">Contact Email</label>
                            <input id="email" type="email" placeholder="Email Address">
                        </div>

                        <div class="pure-control-group">
                            <label for="foo">Website</label>
                            <input id="foo" type="text" placeholder="Enter something here...">
                        </div>

                        <div class="pure-control-group">
                            <label for="foo">Description:</label>
                            <textarea id="description" type="text" placeholder="Enter description here..."></textarea>
                        </div>                      

                        <div class="pure-controls">
                            <label for="cb" class="pure-checkbox">
                                <input id="cb" type="checkbox">
                                I'm interested in an enhanced listing or premium profile, (a member of our team will respond promptly with further information)
                            </label>

                            <button type="submit" class="pure-button pure-button-primary">Submit</button>
                        </div>
                    </fieldset>
                </form>
Run Code Online (Sandbox Code Playgroud)

任何帮助将非常感激.谢谢.

lur*_*ker 15

这是一个简单的方法.可能还有其他人.

<input id="cb" type="checkbox" style="float: left; margin-top: 5px;>">
<div style="margin-left: 25px;">
     I'm interested in an enhanced listing or premium profile,
     (a member of our team will respond promptly with further information)
</div>
Run Code Online (Sandbox Code Playgroud)

我使用a div来"阻止"构造文本并将其移动到右侧.在float: leftinput保持的复选框文字(不超过)的左侧.在margin-topinput与文本调整顶部对齐.

小提琴.


Pau*_*eau 6

这就是我使用的方法。它对我来说比我在 SO 上找到的许多其他方法更有效。

LABEL.indented-checkbox-text
{
  margin-left: 2em;
  display: block;
  position: relative;
  margin-top: -1.4em;  /* make this margin match whatever your line-height is */
  line-height: 1.4em;  /* can be set here, or elsewehere */
}
Run Code Online (Sandbox Code Playgroud)
<input id="myinput" type="checkbox" />
<label for="myinput" class="indented-checkbox-text">I have reviewed the business information and documentation above, and assert that the information and documentation shown is current and accurate.</label>
Run Code Online (Sandbox Code Playgroud)