[css] Parent element flex:1, child element setting height:100% is invalid

The height of the parent is set by setting flex to 1, and then the child wants to maintain the same height as the parent
Since the parent element here is the default, it is set The height is 100% invalid.
You can set the parent height to 0.

.content {
    
    
    flex: 1;
    height: 0;
    .inner{
    
    
      width: 100%;
      height: 100%;
    }
}

At this time, the inner will maintain the same height as the content.


reference:

The parent element flex:1, the height setting of the child element is 100% invalid

おすすめ

転載: blog.csdn.net/qq_14993591/article/details/129613040