美文网首页让前端飞
父元素flex: 1,子元素height: 100%不生效,无法

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

作者: 小光啊小光 | 来源:发表于2020-12-10 13:51 被阅读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%相对应,可以只写其中一种方式, 宽度同理。

相关文章

网友评论

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

    本文链接:https://www.haomeiwen.com/subject/ssalgktx.html