开发者社区> 问答> 正文

子DIV不在父Div内垂直居中对齐

我在div中创建了一个,height: 300px并在其中创建了一个div,另外两个div是display: inline-block。我想做的是让div垂直对齐中心。

我已经尝试过垂直对齐div,使用了flex框(但是如果我使用wrapper,则不会真正起作用margin: 0 auto),也已经使用了line-height(问题是因为我在第二个div中有文本,因此无法解决问题。)

这是我的SCSS代码:

.p-{
    &footer-class{
        height: 47px;
        background: transparent linear-gradient(270deg, #96A3B2 0%, #E9EDF4 100%) 0% 0% no-repeat padding-box;
        @include mq('sm'){
            padding: 0 25px 0 23px;
        }
        @include mq('xs') {
            padding: 0 25px 0 23px;
        }
        @include mq('xl') {
            // justify-content: left;
            // display: flex;
            // align-items: center;
            height: 267px;
           }
      }
   }

   .c-{
        &footer-social {
        float: left;
     }
   }

    .c-{
    &footer-about {
        float: right;
        @include mq('xs'){
            display: inline-block;
            margin-top: 4px;
        }
        @include mq('sm'){
            display: inline-block;
            margin-top: 4px;
        }
        @include mq('md'){
            display: inline-block;
        }
        @include mq('xl'){
            display: inline-block;
        }
    }
    &footer-text {
        display: block;
        color: #ffffff;
        font: bold 10px/20px "Consolas";
        opacity: 1;
        &1 {
            @include mq('xs'){
                display: inline-block;
                margin-top: 4px;
            }
            @include mq('sm'){
                display: inline-block;
                margin-top: 4px;
            }
            @include mq('md'){
                display: inline-block;
            }
            @include mq('xl'){
                display: none;
            }

        }
    }
  }

展开
收起
游客hvab22isfpklc 2019-11-29 10:24:37 1001 0
0 条回答
写回答
取消 提交回答
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载