Why is width: 100% not working on div {display: table-cell}?

前端 未结 7 504
独厮守ぢ
独厮守ぢ 2020-12-25 10:46

I\'m trying to vertically and horizontally center some content overlaying an image slide (flexslider). There were some similar questions to this one, but I couldn\'t find a

7条回答
  •  不知归路
    2020-12-25 11:11

    Your 100% means 100% of the viewport, you can fix that using the vw unit besides the % unit at the width. The problem is that 100vw is related to the viewport, besides % is related to parent tag. Do like that:

    .table-cell-wrapper {
        width: 100vw;
        height: 100%;  
        display: table-cell;
        vertical-align: middle;
        text-align: center;
    }
    

提交回复
热议问题