CSS宽度/高度的IMG和TD [英] CSS width/height of IMG and TD
问题描述
我有一个问题在css,我有一个宽度为100px的TD;和height:100px;在它里面,我有一个img元素具有相同的宽度和高度(100px,100px)。
问题是,TD会自动调整为145px宽和114像素高。
I have a problem in css, I have a TD with a width:100px; and height:100px; inside it, I have an img element with the same width and height (100px, 100px). The problem is that the TD is automatically resized to 145px width and 114 px height.
如果有人知道为什么,以及如何解决它,请帮助我! (这将是巨大的,如果我不需要没有增加我的TD的大小,我的形象必须是100 * 100)
这个问题已经修复,我已经评论过css的一部分。
If anyone know why, and how to solve it please help me! (it would be great if I did not need no increase my TD's size, my image must be 100*100) This problem has been fixed, I had commented that part of the css. But my image is now placed under my text in titleTD and descTD.
以下是HTML
<div id="pixelContent">
<table id="pixelContentTable">
<tr valign=center>
<td id="imageTD" rowspan=2>
<a href=""><img src="" id="contentImage" border="0" width="100px" height="100px"></a></td>
<td id="titleTd">Title here</td>
</tr>
<tr valign=center>
<td id="descTd">Lorem ipsum dolor sit amet, <a href="http://google.com"> nunc in sapien gravida</a> eleifend. Maecenas consectetur, risus id lobortis molestie, magna sapien ullamcorper justo, ultrices </td>
</tr>
</table>
</div>
和CSS:
#pixelContentTable{
margin: 0 auto;
width:400px;
height:120px;
text-align:left;
}
#contentImage{
margin-left:10px;
width:100px;
height:100px;
min-width:100px;
min-height:100px;
max-width:100px;
max-height:100px;
}
#imageTD{
width:100px;
height:100px;
min-width:100px;
min-height:100px;
max-width:100px;
max-height:100px;
}
推荐答案
/ p>
Do it this way:
<table>
<tr>
<td>
<img src="" alt />
</td>
</tr>
</table>
和CSS:
img {
width: 100px;
height: 100px;
display: block;
}
td {
border: 1px solid red;
width: 100px;
height: 100px;
padding: 0;
}
http://codepen.io/Chovanec/pen/otaFb
这篇关于CSS宽度/高度的IMG和TD的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!