CSS - Use calc() to keep widths of elements the same

后端 未结 3 2064
予麋鹿
予麋鹿 2021-02-05 06:08

Is something like this possible in CSS?

elementOne elementt
3条回答
  •  广开言路
    2021-02-05 07:07

    Yes. There are 2 possible ways of doing this with CSS (although not with calc):

    1) If you know how many columns you have, then just use % (i.e. 50% for 2 cols)

    2) If you don't know how many columns you have or you maybe can't use % for whatever use-case you might have, then you can use flexbox. Depending on your browser compatibility target, you can combine the "old" and "new" syntax to get some awesome results.

提交回复
热议问题