将复选框与标签对齐

huangapple go评论57阅读模式
英文:

aligning checkboxes with labels

问题

我无法对复选框与其标签进行对齐,它们会浮动到标签的上方,而在移动设备上,它们会位于标签下方。

问题发生在所有复选框上,所以当你选择“Primary school teacher”选项并从下拉菜单中选择“headteacher”时,问题都会发生。

页面链接为https://careermapforprimary.co.uk/#register

我尝试添加一些CSS但没有起作用。

.mc-field-group input[type="checkbox"] {
    vertical-align: middle;
}

请问有什么建议吗?

这是创建表单字段的代码,没有包含CSS:

<div id="conditional-fields-primary-teacher" style="display: none;">
    <div class="mc-field-group">
        <label for="mce-FNAME">名字 <span class="asterisk">*</span></label>
        <input type="text" value="" name="FNAME" class="required" id="mce-FNAME" required>
    </div>
    <div class="mc-field-group">
        <label for="mce-LNAME">姓氏 <span class="asterisk">*</span></label>
        <input type="text" value="" name="LNAME" class="required" id="mce-LNAME" required>
    </div>
    <div class="mc-field-group">
        <label for="mce-JOB_TITLE">职位 <span class="asterisk">*</span></label>
        <input type="text" value="" name="JOB_TITLE" class="required" id="mce-JOB_TITLE" required>
    </div>
    <div class="mc-field-group">
        <label for="mce-EMAIL">电子邮件地址 <span class="asterisk">*</span></label>
        <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" required>
    </div>
    <div class="mc-field-group">
        <label for="mce-REGION">地区 <span class="asterisk">*</span></label>
        <select name="REGION" class="required" id="mce-REGION" required>
            <option value="">选择...</option>
            <!-- 其他选项... -->
        </select>
    </div>
    <div class="mc-field-group">
        <label>年级/组(选中所有适用项):</label>
        <div>
            <input type="checkbox" name="year-group" value="Reception" id="mce-reception">
            <label for="mce-reception">Reception</label>
        </div>
        <!-- 其他年级选项... -->
    </div>
</div>

希望这对你有所帮助。

英文:

I cant align the checkboxes to their labels, they float one line higher and on mobile they are underneath the label.

Image of the problem

The problem happens on all checkboxes, so when you pick the Primary school teacher option and headteacher from the dropdown.

The link to the page is https://careermapforprimary.co.uk/#register

I've tried to add some CSS but it didn't work.

.mc-field-group input[type=&quot;checkbox&quot;] {
vertical-align: middle;
}

any suggestions please?

This is the code to create the form fields, there is no css:

 &lt;div id=&quot;conditional-fields-primary-teacher&quot; style=&quot;display: none;&quot;&gt;
&lt;div class=&quot;mc-field-group&quot;&gt;
&lt;label for=&quot;mce-FNAME&quot;&gt;First name &lt;span class=&quot;asterisk&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; value=&quot;&quot; name=&quot;FNAME&quot; class=&quot;required&quot; id=&quot;mce-FNAME&quot; required&gt;
&lt;/div&gt;
&lt;div class=&quot;mc-field-group&quot;&gt;
&lt;label for=&quot;mce-LNAME&quot;&gt;Last name &lt;span class=&quot;asterisk&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; value=&quot;&quot; name=&quot;LNAME&quot; class=&quot;required&quot; id=&quot;mce-LNAME&quot; required&gt;
&lt;/div&gt;
&lt;div class=&quot;mc-field-group&quot;&gt;
&lt;label for=&quot;mce-JOB_TITLE&quot;&gt;Job title &lt;span class=&quot;asterisk&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
&lt;input type=&quot;text&quot; value=&quot;&quot; name=&quot;JOB_TITLE&quot; class=&quot;required&quot; id=&quot;mce-JOB_TITLE&quot; required&gt;
&lt;/div&gt;
&lt;div class=&quot;mc-field-group&quot;&gt;
&lt;label for=&quot;mce-EMAIL&quot;&gt;Email Address &lt;span class=&quot;asterisk&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
&lt;input type=&quot;email&quot; value=&quot;&quot; name=&quot;EMAIL&quot; class=&quot;required email&quot; id=&quot;mce-EMAIL&quot; required&gt;
&lt;/div&gt;
&lt;div class=&quot;mc-field-group&quot;&gt;
&lt;label for=&quot;mce-REGION&quot;&gt;Region &lt;span class=&quot;asterisk&quot;&gt;*&lt;/span&gt;&lt;/label&gt;
&lt;select name=&quot;REGION&quot; class=&quot;required&quot; id=&quot;mce-REGION&quot; required&gt;
&lt;option value=&quot;&quot;&gt;Select...&lt;/option&gt;
&lt;option value=&quot;Bedfordshire&quot;&gt;Bedfordshire&lt;/option&gt;
&lt;option value=&quot;Berkshire&quot;&gt;Berkshire&lt;/option&gt;
&lt;option value=&quot;Bristol&quot;&gt;Bristol&lt;/option&gt;
&lt;option value=&quot;Buckinghamshire&quot;&gt;Buckinghamshire&lt;/option&gt;
&lt;option value=&quot;Cambridgeshire&quot;&gt;Cambridgeshire&lt;/option&gt;
&lt;option value=&quot;Cheshire&quot;&gt;Cheshire&lt;/option&gt;
&lt;option value=&quot;Cornwall&quot;&gt;Cornwall&lt;/option&gt;
&lt;option value=&quot;Cumbria&quot;&gt;Cumbria&lt;/option&gt;
&lt;option value=&quot;Derbyshire&quot;&gt;Derbyshire&lt;/option&gt;
&lt;option value=&quot;Devon&quot;&gt;Devon&lt;/option&gt;
&lt;option value=&quot;Dorset&quot;&gt;Dorset&lt;/option&gt;
&lt;option value=&quot;Durham&quot;&gt;Durham&lt;/option&gt;
&lt;option value=&quot;East Sussex&quot;&gt;East Sussex&lt;/option&gt;
&lt;option value=&quot;Essex&quot;&gt;Essex&lt;/option&gt;
&lt;option value=&quot;Gloucestershire&quot;&gt;Gloucestershire&lt;/option&gt;
&lt;option value=&quot;Greater London&quot;&gt;Greater London&lt;/option&gt;
&lt;option value=&quot;Greater Manchester&quot;&gt;Greater Manchester&lt;/option&gt;
&lt;option value=&quot;Hampshire&quot;&gt;Hampshire&lt;/option&gt;
&lt;option value=&quot;Herefordshire&quot;&gt;Herefordshire&lt;/option&gt;
&lt;option value=&quot;Isle of Wight&quot;&gt;Isle of Wight&lt;/option&gt;
&lt;option value=&quot;Kent&quot;&gt;Kent&lt;/option&gt;
&lt;option value=&quot;Lancashire&quot;&gt;Lancashire&lt;/option&gt;
&lt;option value=&quot;Leicestershire&quot;&gt;Leicestershire&lt;/option&gt;
&lt;option value=&quot;Lincolnshire&quot;&gt;Lincolnshire&lt;/option&gt;
&lt;option value=&quot;Merseyside&quot;&gt;Merseyside&lt;/option&gt;
&lt;option value=&quot;Norfolk&quot;&gt;Norfolk&lt;/option&gt;
&lt;option value=&quot;North Yorkshire&quot;&gt;North Yorkshire&lt;/option&gt;
&lt;option value=&quot;Northamptonshire&quot;&gt;Northamptonshire&lt;/option&gt;
&lt;option value=&quot;Northumberland&quot;&gt;Northumberland&lt;/option&gt;
&lt;option value=&quot;Nottinghamshire&quot;&gt;Nottinghamshire&lt;/option&gt;
&lt;option value=&quot;Oxfordshire&quot;&gt;Oxfordshire&lt;/option&gt;
&lt;option value=&quot;Rutland&quot;&gt;Rutland&lt;/option&gt;
&lt;option value=&quot;Shropshire&quot;&gt;Shropshire&lt;/option&gt;
&lt;option value=&quot;Somerset&quot;&gt;Somerset&lt;/option&gt;
&lt;option value=&quot;South Yorkshire&quot;&gt;South Yorkshire&lt;/option&gt;
&lt;option value=&quot;Staffordshire&quot;&gt;Staffordshire&lt;/option&gt;
&lt;option value=&quot;Suffolk&quot;&gt;Suffolk&lt;/option&gt;
&lt;option value=&quot;Surrey&quot;&gt;Surrey&lt;/option&gt;
&lt;option value=&quot;Tyne and Wear&quot;&gt;Tyne and Wear&lt;/option&gt;
&lt;option value=&quot;Warwickshire&quot;&gt;Warwickshire&lt;/option&gt;
&lt;option value=&quot;West Midlands&quot;&gt;West Midlands&lt;/option&gt;
&lt;option value=&quot;West Sussex&quot;&gt;West Sussex&lt;/option&gt;
&lt;option value=&quot;West Yorkshire&quot;&gt;West Yorkshire&lt;/option&gt;
&lt;option value=&quot;Wiltshire&quot;&gt;Wiltshire&lt;/option&gt;
&lt;option value=&quot;Worcestershire&quot;&gt;Worcestershire&lt;/option&gt;
&lt;/select&gt;
&lt;/div&gt;
&lt;div class=&quot;mc-field-group&quot;&gt;
&lt;label&gt;Year/Group (Tick all that apply):&lt;/label&gt;
&lt;div&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Reception&quot; id=&quot;mce-reception&quot;&gt;
&lt;label for=&quot;mce-reception&quot;&gt;Reception&lt;/label&gt;
&lt;/div&gt;
&lt;li&gt;
&lt;div&gt;
&lt;input                 type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Year 1&quot; id=&quot;mce-year1&quot;&gt;
&lt;label for=&quot;mce-year1&quot;&gt;Year 1&lt;/label&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;div&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Year 2&quot; id=&quot;mce-year2&quot;&gt;
&lt;label for=&quot;mce-year2&quot;&gt;Year 2&lt;/label&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Year 3&quot; id=&quot;mce-year3&quot;&gt;
&lt;label for=&quot;mce-year3&quot;&gt;Year 3&lt;/label&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Year 4&quot; id=&quot;mce-year4&quot;&gt;
&lt;label for=&quot;mce-year4&quot;&gt;Year 4&lt;/label&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Year 5&quot; id=&quot;mce-year5&quot;&gt;
&lt;label for=&quot;mce-year5&quot;&gt;Year 5&lt;/label&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;input type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Year 6&quot; id=&quot;mce-year6&quot;&gt;
&lt;label for=&quot;mce-year6&quot;&gt;Year 6&lt;/label&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;

答案1

得分: 1

<div class="input-wraper">
  <input class="input" type="checkbox" name="year-group" value="Reception" id="mce-reception">
  <label for="mce-reception" style="display: inline-block">Reception</label>
</div>
.input-wraper {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  margin: 3px 4px 3px 3px;
}
.input {
  vertical-align: middle;
  margin: 0;
}
英文:
&lt;div class=&quot;input-wraper&quot;&gt;
  &lt;input class=&quot;input&quot; type=&quot;checkbox&quot; name=&quot;year-group&quot; value=&quot;Reception&quot; id=&quot;mce-reception&quot;&gt;
  &lt;label for=&quot;mce-reception&quot; style=&quot;display: inline-block&quot;&gt;Reception&lt;/label&gt;
&lt;/div&gt;
.input-wraper {
  display: flex;
  align-items: center;
  flex-direction: row-reverse;
  margin: 3px 4px 3px 3px;
}
.input {
  vertical-align: middle;
  margin: 0;
}

答案2

得分: 0

尝试移除 width: 100% 并将您的输入和标签设置为 display: inline-block

英文:

The problem is here :

#mc_embed_signup .mc-field-group input {
  display: block;
  width: 100%;
  padding: 8px 0;
  text-indent: 2%;
}

Try to remove the width: 100% and turn you're input and label on display: inline-block

huangapple
  • 本文由 发表于 2023年3月31日 17:38:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75896966.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定