How to display inline several
  • with 100% width?
  • 后端 未结 7 1390
    灰色年华
    灰色年华 2020-12-21 01:24

    I have the following html:

    • element 1
    • element 2
    <
    7条回答
    •  情深已故
      2020-12-21 01:52

      What you're trying to do resembles what table cells do and is impossible otherwise, without using JavaScript (I don't suggest using tables or JavaScript for this, however). Your best bet is to set a certain amount of horizontal padding on the

    • tags and float them so that they are auto-width based on their content's width instead of the window's width:

      • element 1
      • element 2

      The other method is to use display: inline-block; to achieve what you want, but it's kind of a hack (not cross-browser compatible).

    提交回复
    热议问题