复选框链接 - 显示内联和浮动左边不起作用

问题描述 投票:1回答:1

我正在将一个Mailchimp注册表单连接到我的Wordpress网站https://thetekworks.com - 但是GDPR复选框没有按照我的预期执行...查看我的隐私政策的链接应该出现在我的复选框之后但它出现在一个新行上。

我尝试使用浮动和显示标签来纠正这个,因为我在网上找到但这也没有用。

<p>
<input type="email" name="EMAIL" placeholder="Email address*" required />
    <label>
      <input style="float:left; display:inline" name="AGREE_TO_TERMS" type="checkbox" value="1" required="">
      <a href="https://thetekworks.com/privacy-policy/" target="_blank">I have read and agree to your privacy policy</a>
</label>

我原以为它的表现与https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_input_checked相似

任何帮助将不胜感激。

html css wordpress mailchimp
1个回答
0
投票

更新

在直接查看您的网站后,请尝试使用以下CSS

.mc4wp-form-basic label {
  display: flex;
  align-items: center;
}

添加之后,我看到以下结果:

enter image description here


我认为你需要从父元素组织布局(在本例中为<p>)。使用flexbox,我们可以堆叠电子邮件inputlabel(s)并删除对float的需求。我还将您的术语的一部分链接为纯文本,以便label实际上是可点击的,而不仅仅是一个链接。单击标签的文本应切换与其关联的复选框状态。

p {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

[type="email"] {
  margin-bottom: 1em;
}

label {
  cursor: pointer;
  -moz-user-select: none;
  -webkit-user-select: none;
  user-select: none;
}
<p>
  <input type="email" name="EMAIL" placeholder="Email address*" required />
  <label>
      <input name="AGREE_TO_TERMS" type="checkbox" value="1" required="">
      I have read and agree to your<a href="https://thetekworks.com/privacy-policy/" target="_blank"> privacy policy</a>
  </label>
  <label>
      <input name="SOMETHING ELSE" type="checkbox" value="2" required="">
      Another checkbox label
  </label>  
</p>
© www.soinside.com 2019 - 2024. All rights reserved.