Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
412 views
in Technique[技术] by (71.8m points)

html - css inline-block vs table-cell

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; vertical-align: middle; etc. by identifying display: inline-block; or display: table-cell; would work the same.

Please notify the key differences.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...