Resize unknown number of elements to fill width of parent container

后端 未结 3 738
长情又很酷
长情又很酷 2020-12-31 17:36

I need to put an unknown number of divs (likely a limit of about 5) into a parent container and always make sure they remain equally divided. I\'m not sure if this can be do

3条回答
  •  天涯浪人
    2020-12-31 18:05

    Try this solution (demo page).

    Basically, you need to make the divs display:inline-block, and apply text-align:justify to them. Then force a line break. One drawback is there will always be some space between divs, i.e. no way to make their edges touch.

提交回复
热议问题