Let span fill remaining width?

前端 未结 3 1473
有刺的猬
有刺的猬 2021-01-03 19:10

I have the following li item:

  • a
  • 相关标签:
    3条回答
    • 2021-01-03 19:50

      Looked for the same solution, but found only this which worked great for me:

      <li>
        <span style='display: table-cell; background-color:red'>a</span>
        <span style='display: table-cell; width: 100%; background-color:green'>b</span>
      </li>
      

      All you need is just using table-cell displaying and set filler span width to 100%. All other solutions I've tried didn't work for me as expected.

      0 讨论(0)
    • 2021-01-03 20:03

      Don't float the second one, and make it display:block.

      http://jsfiddle.net/ymAt5/

      0 讨论(0)
    • 2021-01-03 20:08

      You don't want to float each of them left, only the first one, and then make the second one display in block mode:

      <li>
        <span style='float:left; background-color:red'>a</span>
        <span style="display: block; background-color:green;">b</span>
      </li>
      
      0 讨论(0)
    提交回复
    热议问题