When flexbox items wrap in column mode, container does not grow its width

后端 未结 6 1972
长情又很酷
长情又很酷 2020-11-21 05:22

I am working on a nested flexbox layout which should work as follows:

The outermost level (ul#main) is a horizontal list that must expand to the right w

6条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-21 06:12

    It is unfortunate that so many major browsers suffer from this bug after many years. Consider a Javascript workaround. Whenever the browser window resizes, or content is added to the element, execute this code to get it to resize to the proper width. You can define a directive in your framework to do it for you.

        element.style.flexBasis = "auto";
        element.style.flexBasis = `${element.scrollWidth}px`;
    

提交回复
热议问题