【问题标题】:form wrapper is not responsive表单包装器没有响应
【发布时间】:2019-02-04 05:37:54
【问题描述】:

我正在尝试设计注册表单,其中将有不同颜色的两侧背景,并且注册表单应位于该背景上方并位于中心。我可以按照我解释的方式进行设计,但响应速度不够快。主要是因为手机设计不太顺利。对于移动设备,应该只有简单的注册表单。可能是我在定位(相对,绝对)部分犯了错误。

这就是我所做的

html

.signup-form {
  width: 100%;
  min-height: 100vh;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  background: #f2f2f2;
}

.signup-wrapper {
  width: 100%;
  background: #6493f3;
  overflow: hidden;
  display: -webkit-box;
  display: -webkit-flex;
  display: -moz-box;
  display: -ms-flexbox;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  flex-direction: row-reverse;
}

.left-block {
  width: calc(100% - 560px);
  background: #6493f3;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  z-index: 1;
  &::before {
    content: '';
    display: block;
    position: absolute;
    z-index: -1;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.1);
  }
}

.right-block {
  width: 560px;
  min-height: 100vh;
  display: block;
  background-color: #f7f7f7;
  padding: 50px 55px 55px 55px;
  position: relative;
}

form {
  background: #fff;
  box-shadow: 0 1.5px 0 0 rgba(0, 0, 0, 0.1);
  position: absolute;
  top: 120px;
  left: -100px;
  width: 450px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px;
}

.caption {
  width: 100%;
  display: flex;
  font-size: 30px;
  color: #444;
  line-height: 1.2;
  text-align: center;
  padding: 20px;
  flex: 1;
  justify-content: center;
  align-items: center;
}

.form-field {
  display: -webkit-box;
  display: -webkit-flex;
  display: -ms-flexbox;
  display: flex;
  margin-bottom: 2rem;
}
<div class="signup-form">
  <div class="signup-wrapper">
    <div class="right-block">
      <form>
        <span class="caption">Create An Account</span>
        <div class="form-field">
          <input type="text" placeholder="full name" />
        </div>
        <div class="form-field">
          <input type="email" placeholder="email" />
        </div>
        <div class="form-field">
          <input type="password" placeholder="password" />
        </div>
        <div class="form-field">
          <input type="text" placeholder="country" />
        </div>
      </form>
    </div>
    <div class="left-block">
    </div>
  </div>
</div>

jsbin文件在这里http://jsbin.com/ritinedeku/1/edit?html,css

更新

这就是我想要达到的目标。

【问题讨论】:

    标签: html css responsive-design flexbox


    【解决方案1】:

    .signup-form { 
      width: 100%;
      min-height: 100vh;
      display: -webkit-box;
      display: -webkit-flex;
      display: -moz-box;
      display: -ms-flexbox;
      display: flex;
      flex-wrap: wrap;
      justify-content: center;
      align-items: center;
      background: #f2f2f2;
    }
    
    
    .signup-wrapper{
      width: 100%;
      background: #6493f3;
      overflow: hidden;
      display: -webkit-box;
      display: -webkit-flex;
      display: -moz-box;
      display: -ms-flexbox;
      display: flex;
      flex-wrap: wrap;
      align-items: stretch;
      flex-direction: row-reverse;
    }
    
    .left-block{
      width: calc(100% - 560px);
      background: #6493f3;
      background-repeat: no-repeat;
      background-size: cover;
      background-position: center;
      z-index: 1;
      &::before {
        content: '';
        display: block;
        position: absolute;
        z-index: -1;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        background: rgba(0, 0, 0, 0.1);
      }
    }
    
    .right-block{
      width: 50%;
      min-height: 100vh;
      display: block;
      background-color: #f7f7f7;
      padding: 0;
      position: relative;
    }
    
    form {
            background: #fff;
    box-shadow: 0 1.5px 0 0 rgba(0, 0, 0, 0.1);
    position: absolute;
    top: 120px;
    left: 0;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    z-index: 99;
    right: 0;
    margin: auto;
    width: 75%;
    }
    
    .caption {
      width: 100%;
      display: flex;
      font-size: 30px;
      color: #444;
      line-height: 1.2;
      text-align: center;
      padding: 20px;
      flex: 1;
      justify-content: center;
      align-items: center;
    }
    
    .form-field {
      display: -webkit-box;
      display: -webkit-flex;
      display: -ms-flexbox;
      display: flex;
      margin-bottom: 2rem;
    }
    <div class="signup-form">
      <div class="signup-wrapper">
         <form>
            <span class="caption">Create An Account</span>
            <div class="form-field">
              <input type="text" placeholder="full name" />
            </div>
            <div class="form-field">
              <input type="email" placeholder="email" />
            </div>
            <div class="form-field">
              <input type="password" placeholder="password" />
            </div>
            <div class="form-field">
              <input type="text" placeholder="country" />
            </div>
          </form>
        <div class="right-block">
         
        </div>
        <div class="left-block">
        </div>
      </div>
    </div>

    【讨论】:

    • 感谢您的回答。请把它做成可执行代码好吗?
    • 让我试试等一下
    • 代码现在可执行
    • 表单看起来不像 OP 的示例。
    • 目的是将表格\设置在中间,左右两边相等。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-08-27
    • 2017-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-18
    • 1970-01-01
    相关资源
    最近更新 更多