开发者

Forcing a certain width/height with overflow in a <td>

I have a <table> with table-layout set to fixed, so that all explic开发者_JS百科it width/height definitions are respected no matter what. I'm trying to get a certain <td> to overflow, but even though I did the table-layout: fixed it doesn't work.

What should I do to make it work?


It won't work because the <td> will always have the size of an image


You can use height and width attributes. If the image size is 400x300, typing <img src="..." height="100" width="100" /> will show 100x100 image

If you want to crop an image use

<style>
#id{
background:url(...) no-repeat; /* you can use background-position css property here... */
height:100px;
width:100px;
</style>
<div id="image"></div>


Using table-layout: fixed, you can only guarantee the column widths, not heights. Also, the content of cells has no bearing on those widths. From w3schools:

The horizontal layout only depends on the table's width and the width of the columns, not the contents of the cells.

How much control do you need over the individual cells? Are you going for hidden overflow or one that can scroll? It's not clear from your question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜