表单包装没有响应

时间:2018-08-29 12:18:15

标签: html css responsive-design flexbox

我正在尝试设计注册表单,该表单的两侧将有不同颜色的背景,并且注册表单应位于该背景的正上方并位于中间。我可以设计我所解释的方式,但反应不够灵敏。主要用于移动设备设计,效果不佳。对于移动设备,仅应使用简单的注册表格。可能是我在定位(相对,绝对)部分时犯了错误。

这是我所做的

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

更新

这是我要实现的目标。

enter image description here

1 个答案:

答案 0 :(得分: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>