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

后端 未结 9 1155
有刺的猬
有刺的猬 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:50

    This is the quick and easy way to do it

    Span 1 Span 2 Span 3

    css

    div{
        width:100%;
    }
    span{
        display:inline-block;    
        width:33%;
        text-align:center;
    }
    

    Then adjust the width of the spans for the number you have.

    Example: http://jsfiddle.net/jasongennaro/wvJxD/

提交回复
热议问题