css inline-block vs table-cell

前端 未结 2 1110
伪装坚强ぢ
伪装坚强ぢ 2020-12-10 01:41

What are the differences between inline-block and table-cell?

I have found these two styles are the same. Whatever you style for eg. text-align: center; verti

2条回答
  •  青春惊慌失措
    2020-12-10 01:55

    display: table-cell and display: inline-block; are confusing the same but it has huge difference between them. display: inline-block; will not behave as the display: table-cell; i.e. inline-block will behave as the block level when your browser will be re-sized larger or if your contents exceeds than its width while display: table-cell; won't.

    You can see the differences between them here

    You'll also find the gap between block when you apply display: inline-block; Re-size your window by pressing Ctrl key and scrolling with mouse scroll button to see differences.

    Notice the vertical-align: middle; is not working as display: table-cell; in display: inline-block;. If you have working demo please share one.

提交回复
热议问题