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

前端 未结 7 502
独厮守ぢ
独厮守ぢ 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:24

    Welcome to 2017 these days will using vW and vH do the trick

    html, body {
        margin: 0; padding: 0;
        width: 100%; height: 100%;
    }
    
    ul {
        background: #CCC;
        height: 100%;
        width: 100%;
        list-style-position: outside;
        margin: 0; padding: 0;
    }
    
    li {
        width: 100%;
        display: table;
    }
    
    img {
        width: 100%;
        height: 410px;
    }
    
    .outer-wrapper {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        margin: 0; padding: 0;
    }
    
    .inner-wrapper {
        display: table-cell;
        vertical-align: middle;
        text-align: center;
        width: 100vw; /* only change is here "%" to "vw" ! */
        height: 100vh; /* only change is here "%" to "vh" ! */
    }
    • My Title

      Subtitle

提交回复
热议问题