css - 验证错误向右移动按钮 - CSS

标签 css

.password-reset {
  padding: 40px 50px 0;
  float: left;
}
.form-field {
  float: left;
  font-size: 18px;
  color: #fff;
  margin-right: 15px;
}
.form-field--wide {
  width: 100%;
  float: left;
  margin-bottom: 20px;
}
.form-field label {
  margin-bottom: 3px;
  width: 100%;
  display: block;
  color: black;
}
.form-field input {
  padding: 10px;
  color: #000;
  width: 245px;
  float: left;
}
.form-field input.error {
  color: #ed1b2e;
}
.form-field--half {
  width: 48%;
  margin: 0;
}
.form-field--half input {
  width: 100%;
}
.form-field--repos {
  float: right;
}
.form-error {
  color: #ed1b2e;
  font-size: 14px;
  float: left;
  margin: 5px 3px 0 0;
  display: inline-block;
}
.form-error.alert {
  clear: both;
}
.form-error ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.form-error li {
  /*display: inline-block;*/
  margin-right: 3px;
}
.form-field--wide .form-error {
  font-size: 18px;
  color: #ed1b2e;
  padding: 0 10px;
  font-size: 18px;
  width: 180px;
  float: left;
  line-height: normal;
  margin-top: 0;
}
<div class="password-reset">
  <form id="passwordReminderForm" action="/service/public/passwordReminder.do?siteLanguage=en" method="post">
    <div class="form-field form-field--half">
      <label for="user">Username</label>
      <div class="input error-input">
        <input id="passwordReminderFormUsername" name="username" value="" type="text">
      </div>
    </div>
    <!-- .form-field -->

    <div class="form-field form-field--half form-field--repos">
      <label for="email">E-mail</label>
      <div class="input error-input">
        <input style="width: 120%;" id="passwordReminderFormEmail" name="email" value="" type="text">
      </div>
    </div>
    <!-- .form-field -->
    <div class="verification-messages message--red">
      <div id="passwordReminderForm.errors" class="form-error">"E-mail" must be set
        <br>"Username" must be set</div>
    </div>
    <input class="btn btn--top-offset js-validate-image submit-form" value="Remind Me" type="submit">
    <input name="_csrf" value="7035c910-22bf-49b9-b0b3-facd9d460fbd" type="hidden">
  </form>
</div>

我提供了 CSS 和 HTML 代码。如您所见,问题是验证错误将“提醒我”按钮移到了右侧,但它应该始终位于左侧。我怎样才能做到这一点?有什么建议么?如果需要,我会提供按钮样式。 link to fiddle

最佳答案

您需要先清除继承的左侧,然后使用 css 将 float float left 应用到按钮上

.form-submit-button{
    clear:left;
    float:left;
}
<input class="btn btn--top-offset js-validate-image submit-form form-submit-button" value="Remind Me" type="submit">

这是js fiddle

Demo code

关于css - 验证错误向右移动按钮 - CSS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32197851/

相关文章:

javascript - Document.querySelector() 不适用于 bootstrap css

css - 文本溢出 :ellipsis; not truncating overflowing text and giving ellipsis

Jquery 点击功能适用于桌面,但不适用于移动设备

css - fontawesome : stacked icons not displaying correctly

html - 导航/标题和媒体查询问题

css - IFrame mic flash授权内容超出可见区域

html - 歌剧布局问题在 fiddle 中起作用但在实时网站中不起作用——如何

html - 内容未在 IE 中显示

javascript - 如何更改具有相同类名的元素的样式

jquery - 如何根据值的大小显示div