让前端飞

父元素flex: 1,子元素height: 100%不生效,无法

2020-12-10  本文已影响0人  小光啊小光
/* 方法1(仅chrome生效,不兼容safari) */
.father{
    height: 0;
}

/* 方法2 */
.father{
    position: relative;
}
.son{
    position: absolute;
    height: 100%;
    top: 0;
    bottom: 0;
}
// 如果你需要width也充满,只需要在son上添加
.son {
    width: 100%;
    left:0;
    right: 0;
}

// 其实too:0 bottom:0与 height: 100%相对应,可以只写其中一种方式, 宽度同理。
上一篇 下一篇

猜你喜欢

热点阅读