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

I have a <table> with table-layout set to fixed, so that all explicit width / height definitions are respected no matter what. I am trying to override a specific <td> , but even if I made table-layout: fixed , it does not work.

What to do to make it work?

0
source share
2 answers

This will not work, because <td> will always have image size


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

If you want to crop the 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> 
+1
source

Using table-layout: fixed , you can guarantee the width of the columns, not the height. In addition, the cell content does not affect these widths. From w3schools:

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

How much control do you need over individual cells? Are you going to use hidden overflow or one that can scroll? This is not clear from your question.

0
source

Source: https://habr.com/ru/post/1343502/


All Articles