如何将容器和标签与Bootstrap中的复选框对齐?

问题描述

我想实现这一目标。这是一个onclick弹出窗口。

enter image description here

到目前为止,这就是我所做的。

enter image description here

如您所见,它占据了整个页面,我不知道为什么,并且没有办法将标签与复选框对齐,因为标签显示在复选框下方,并且我无法移动它们。我真的很喜欢一些建议,这个想法是使用引导程序。我尝试阅读一些文档,但是在我刚开始的时候,我真的很难理解所有内容

CSS:

body{
    padding:0;
    margin:0;
  }
  
  .signupContainer{
    height:100%;
    position:absolute;
    overflow:hidden;
    background-color: white;
    Box-shadow: 15px 9px 26px rgba(0,0.2);
    border-radius: 20px;
    margin: 0 auto;
  }

  .Box{
    position:absolute;
    height:100%;
    width:50%;
    margin-top: 55px;
    font-family: 'Poppins',sans-serif;     
    padding-bottom: 140px;
  }

  .Box h1{
    text-align:center;
    margin: 0 auto;
    font-size:30px;
    margin-bottom: 20px;
  }
  
  .Box input{
    font-family: 'Poppins',sans-serif;
    display:block;
    width:300px;
    margin:0px auto;
    padding:5px;
    text-align: center;
    background: #F8F8F8;
    color:#fff;
    border:0;
    border-radius: 20px;
    margin-bottom: 20px
  }
  .Box input:focus,.Box input:active,.Box button:focus,.Box button:active{
    outline:none;
  }

  .Box label {
      font-family: 'Poppins',sans-serif;
  }

  .Box button{
    background: #FE6047;
    border:0;
    color:#fff;
    padding:5px;
    font-size:20px;
    width:300px;
    margin:20px auto;
    display:block;
    cursor:pointer;
    border-radius: 20px;
  }
  .Box button:active{
    background:#27ae60;
  }
  .Box p{
    font-size:14px;
    text-align:center;
  }
  .Box p span{
    cursor:pointer;
    color:#666;
  }

  input[type=checkBox] {
    margin: 2px 0 0;
    align-self: flex-start;
}

HTML:

    <div class="signupContainer col-6">
      <div class="Box col-12">
        <h1 class="col">Sign up</h1>
        <input type="text"  class="col" placeholder="Usuario"/>
        <input type="email" class="col" placeholder="Email"/>
        <input type="text"  class="col" placeholder="Pais"/>
        <input type="password" class="col" placeholder="Contraseña"/>
        <input type="password" class="col" placeholder="Repite contraseña"/>
         <label for="seller" class="checkBox-inline"><input type="checkBox" id="seller" >vendedor</label>
       <label for="buyer" class="checkBox-inline"><input type="checkBox" id="buyer" > Comprador</label>
        <button class="col">Sign</button>
      </div>
    </div>

谢谢!

解决方法

尝试一下:

HTML:

<div class="ContainerSignUp">
  <div class="ContainerHeaderBG"></div>
  <div class="signupContainer col-6">
    <div class="box col-12">
      <h1 class="col">Sign up</h1>
      <input type="text"  class="col" placeholder="Usuario"/>
      <input type="email" class="col" placeholder="Email"/>
      <input type="text"  class="col" placeholder="Pais"/>
      <input type="password" class="col" placeholder="Contraseña"/>
      <input type="password" class="col" placeholder="Repite contraseña"/>
      <label for="seller" class="checkbox-inline">
        <input type="checkbox" id="seller">Vendedor
      </label>
      <label for="buyer" class="checkbox-inline">
        <input type="checkbox" id="buyer">Comprador
      </label>
      <button class="col">Sign</button>
    </div>
  </div>
</div>

CSS:

body {
    padding: 0;
    margin: 0;
}

.ContainerSignUp {
  position: relative;
  background: blue;
}

.ContainerHeaderBG {
  width: 100%;
  height: 200px;
  background: green;
}

.signupContainer {
  width: 500px;
  max-width: 90%;
  top: 100px;
  left: 50%;
  transform: translateX(calc(-50% + 0.1px));
    position: absolute;
    overflow: hidden;
    background-color: white;
    box-shadow: 15px 9px 26px rgba(0,0.2);
    border-radius: 20px;
    margin: 0 auto;
}

.box h1 {
    text-align: center;
    margin: 100px auto 0;
    font-size: 30px;
    margin-bottom: 20px;
}

.box input {
    font-family: 'Poppins',sans-serif;
    display: block;
    width: 80%;
    margin: 0px auto;
    padding: 5px 20px;
    text-align: left;
    background: #F8F8F8;
    color: #fff;
    border: 0;
    border-radius: 20px;
    margin-bottom: 20px;
  color: #000;
}

.box input:focus,.box input:active,.box button:focus,.box button:active {
    outline: none;
}

.box label {
    font-family: 'Poppins',sans-serif;
  display: block;
  width: 80%;
  margin: auto;
}

.box button {
    background: #FE6047;
    border: 0;
    color: #fff;
    padding: 5px;
    font-size: 20px;
    width: 300px;
    margin: 20px auto;
    display: block;
    cursor: pointer;
    border-radius: 20px;
}

.box button:active {
    background: #27ae60;
}

.box p {
    font-size: 14px;
    text-align: center;
}

.box p span {
    cursor: pointer;
    color: #666;
}

input[type=checkbox] {
    margin: 2px 0 0;
    align-self: flex-start;
}


/* Modification */

input#seller,input#buyer {
    display: inline;
    width: 11px;
    margin-right: 10px;
}

我在CodePen中发布的示例:
CodePen Example