This table has 2 columns and 5 rows; in each cell I put an image and I need that image to fit the td
dimensions.
Here is my HTML and CSS code:
#menu{
float:right;
width:200px;
height:650px;
border-bottom:none;
border-left:solid 1px;
}
#menu img{
width:100%; height:auto;;
}
td{
border:solid 1px;
}
<table id="menu" cellspacing="0">
<tr><td class="item"><img src="../mke.jpg"/></td><td class="item"><img src="../mke.jpg"/></td></tr>
<tr><td class="item"><img src="../mke.jpg"/></td><td class="item"><img src="../mke.jpg"/></td></tr>
<tr><td class="item"><img src="../mke.jpg"/></td><td class="item"><img src="../mke.jpg"/></td></tr>
<tr><td class="item"><img src="../mke.jpg"/></td><td class="item"><img src="../mke.jpg"/></td></tr>
</table>
What I got is this:
The images doesn't fit all the cells.
How can I re-size these images? I need a suggestion which works with IE9.
To set the cell width and height, use the CSS style. The height and width attribute of the <td> cell isn't supported in HTML5. Use the CSS property width and height to set the width and height of the cell respectively. Just keep in mind, the usage of style attribute overrides any style set globally.
The second is to click in each table, go to the Table Tools > Layout tab, click the AutoFit button, and choose Fixed Column Width. With those settings, you can drag a picture from Windows Explorer, or use the Insert > Picture dialog, to insert one picture into one cell.
Step 1: Firstly, we have to type the Html code in any text editor or open the existing Html file in the text editor in which we want to change the size of an image. Step 2: Now, place the cursor inside the img tag. And then, we have to use the height and width attribute of the img tag for changing the size of an image.
Just make the images width to 100% and make the height auto to keep the images from looking distorted
so something like
#menu img{
display:block; width:100%; height:auto;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With