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

/* 方法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%相对应,可以只写其中一种方式, 宽度同理。
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。