【问题标题】:Flex Half bootstrapFlex 半自举
【发布时间】:2021-11-28 20:37:25
【问题描述】:

如何将图像从右侧移动到左侧?以及从左侧到右侧的表格?我还是新手,所以我不知道该怎么做。

Image

这里是html代码。

  <div class="d-lg-flex half">
    <div class="bg order-1 order-md-2" style="background-image: url('images/register.svg');"></div>
    <div class="contents order-2 order-md-1">

      <div class="container">
        <div class="row align-items-center justify-content-center">
          <div class="col-md-7">
              <div class="form-group first">
                <label for="username">Email</label>
                <input type="email" class="form-control" required>
              </div>

              <input type="submit" value="Login" class="btn btn-primary">

          </div>
        </div>
      </div>
    </div>
  </div>

这是css。

.half, .half .container > .row {
  height: 100vh;
  min-height: 700px; }

@media (max-width: 991.98px) {
  .half .bg {
    height: 200px; } }

.half .contents {
  background: #f6f7fc; }

.half .contents, .half .bg {
  width: 50%; }
  @media (max-width: 1199.98px) {
    .half .contents, .half .bg {
      width: 100%; } }
  .half .contents .form-control, .half .bg .form-control {
    border: none;
    -webkit-box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    height: 54px;
    background: #fff; }
    .half .contents .form-control:active, .half .contents .form-control:focus, .half .bg .form-control:active, .half .bg .form-control:focus {
      outline: none;
      -webkit-box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
      box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1); }

.half .bg {
  background-size: cover;
  background-position: center; }

.half a {
  color: #888;
  text-decoration: underline; }

.half .btn {
  height: 54px;
  padding-left: 30px;
  padding-right: 30px; }

.half .forgot-pass {
  position: relative;
  top: 2px;
  font-size: 14px; }

请帮助我真的想将图像移到左侧,将表单移到右侧。但我不知道怎么做的。

【问题讨论】:

    标签: css twitter-bootstrap-3


    【解决方案1】:

    删除 img 容器的 order-md-2 类,因为它会将 img 发送到右侧。

    .half, .half .container > .row {
      height: 100vh;
      min-height: 700px; }
    
    @media (max-width: 991.98px) {
      .half .bg {
        height: 200px; } }
    
    .half .contents {
      background: #f6f7fc; }
    
    .half .contents, .half .bg {
      width: 50%; }
      @media (max-width: 1199.98px) {
        .half .contents, .half .bg {
          width: 100%; } }
      .half .contents .form-control, .half .bg .form-control {
        border: none;
        -webkit-box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
        box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
        border-radius: 4px;
        height: 54px;
        background: #fff; }
        .half .contents .form-control:active, .half .contents .form-control:focus, .half .bg .form-control:active, .half .bg .form-control:focus {
          outline: none;
          -webkit-box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
          box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1); }
    
    .half .bg {
      background-size: cover;
      background-position: center; }
    
    .half a {
      color: #888;
      text-decoration: underline; }
    
    .half .btn {
      height: 54px;
      padding-left: 30px;
      padding-right: 30px; }
    
    .half .forgot-pass {
      position: relative;
      top: 2px;
      font-size: 14px; }
     <link rel= stylesheet href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.0.2/css/bootstrap.min.css">
     <div class="d-lg-flex half">
        <div class="bg order-1" style="background-image: url('https://picsum.photos/200/300');"></div>
        <div class="contents order-2 order-md-1">
    
          <div class="container">
            <div class="row align-items-center justify-content-center">
              <div class="col-md-7">
                  <div class="form-group first">
                    <label for="username">Email</label>
                    <input type="email" class="form-control" required>
                  </div>
    
                  <input type="submit" value="Login" class="btn btn-primary">
    
              </div>
            </div>
          </div>
        </div>
      </div>

    codepenhere

    PS:全屏打开

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-18
      • 1970-01-01
      • 1970-01-01
      • 2011-07-24
      • 1970-01-01
      • 2018-11-25
      • 1970-01-01
      相关资源
      最近更新 更多