Image expands the table cell

白昼怎懂夜的黑 提交于 2020-01-15 05:17:34

问题


I have an 600x90 picture and I want a table cell with exactly 600x90 dimensions.

But I tried overflow:hidden and some other solution on the net, but it still expands the table cell for a couple of pictures.

The best I could get so far is 600x93 but it leaves 3 empty pixels at the bottom, which looks very awkward!

Can someone help me on finding a solution?


回答1:


images by default have

display:inline

which in most browsers adds 3-5 pixels to it's height.

Try setting the css for the picture like this:

table.myTable td.withImage img { display:block; }

and see if it works.




回答2:


I've seen this happen in some browsers where the default image display type is inline, and it sits above some imaginary line. Try adding display:block to your image class.

If this doesn't help, let us know if its a cross-browser problem or just FF/IE/whatever. Also an example could help.



来源:https://stackoverflow.com/questions/5791033/image-expands-the-table-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!