html - div的背景色只覆盖50%

标签 html css

我正在尝试让我的 div (#signupform) 在 div 的整个高度上显示浅灰色背景色。

而是在电子邮件输入字段结束时停止。

我怎样才能做到这一点?

实例:https://www.moneynest.co.uk/frustrating-newsletter-signup-box/

#signupform {
  background-color: lightgray;
}

#signupinput {
  display: block;
  text-align: center;
  max-width: 50%;
}

.email-sign-up-headline {
  padding-top: 10px!important;
}

#mcsignupbutton {
  width: 50%;
  display: block;
  text-align: center;
  margin-left: 25%;
}

#mcinputform {
  max-width: 50%;
  display: block;
  text-align: center;
}
<div id="signupform" style="background-color: lightgrey;">
  <center>
    <h3 class="email-sign-up-headline">Subscribe to the private Money Nest newsletter</h3>
  </center>
  <form action="https://moneynest.us11.list-manage.com/subscribe/post?u=9ccf2d2219536b32eaae3c3d1&amp;id=33b662ad0d" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
      <center><input type="email" value="" name="EMAIL" class="email" id="mcinputform" placeholder="email address" required></center><input id="group_8" style="display: none;" checked="checked" name="group[12353][32]" type="checkbox" value="1" />
      <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
      <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_9ccf2d2219536b32eaae3c3d1_33b662ad0d" tabindex="-1" value=""></div>
      <div class="clear">
        <center><input type="submit" value="Subscribe" name="subscribe" id="mcsignupbutton"></center>
      </div>
    </div>
  </form>
</div>

最佳答案

这是因为 div.clear 中的 input[type="submit"] 向左浮动,而 .clear div在它之后没有任何东西可以清除那个 float 。要解决此问题,请将其添加到 .clear div:

.clear::after {
    content: '';
    clear: both;
    display: block;
}

关于html - div的背景色只覆盖50%,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48526930/

相关文章:

php - 使用哪个正则表达式来确定要为 html 属性和 javascript 转义哪些字符?

javascript - 如何使用 HTML、CSS 和 JavaScript 制作时间轴?

html - 在三个相邻图像上方居中文本链接

javascript - 数字的表单验证

javascript - 创建可折叠菜单和子菜单时如何固定间距

html - 如何删除面板底部多余的空白区域

html - iPhone 6 : position fixed scrolling issue

asp.net - 为什么按钮的文本不受包含按钮的容器上的 css 样式规则的约束?

html - 图像上的响应式文本

html - @supports 规则如何支持此语句中的动画名称?