how to evenly distribute elements in a div next to each other?

后端 未结 9 1140
有刺的猬
有刺的猬 2020-12-02 07:26

This is meant for a menu.
For example I have a div element with 3 spans in it, all of which have some margin, max-width and float (left or right).
It is positioned s

9条回答
  •  攒了一身酷
    2020-12-02 07:54

    Make all spans used inline-block elements. Create an empty stretch span with a 100% width beneath the list of spans containing the menu items. Next make the div containing the spans text-align: justified. This would then force the inline-block elements [your menu items] to evenly distribute.

    https://jsfiddle.net/freedawirl/bh0eadzz/3/

      
    

提交回复
热议问题