Distribute elements evenly using CSS

后端 未结 13 879
一生所求
一生所求 2020-12-09 02:55

A method to distribute elements evenly in a container using CSS appeared on Smashing Magazine today.

I recently had to use Javascript to achieve the same effect for

13条回答
  •  不知归路
    2020-12-09 03:24

    This is what display:table-cell is supposed to achieve - however, the IE's just don't do it, and FF<3 has problems with it too, I believe.

    These styles work in FF3, Chrome, Safari, and (I think) Opera 9:

    #menu ul {display:table;padding:0;}
    #menu li {display:table-cell;text-align:center;}
    

    But you'll need a fair few hacks to get them working in the usual, commercial set of browsers.

提交回复
热议问题