简体   繁体   English

图片中 <TD> 不适合整个单元格。 (在FF中可以正常工作,但在IE中则不能)

[英]Image in <TD> not fitting the complete cell. (works fine in FF, but not in IE)

I am trying to add a background image for element in the following way in css 我正在尝试以以下方式在CSS中为元素添加背景图片

CSS CSS

.datebox {
    background-image: url("datebox.png");
    background-size: 100%;
    background-repeat: no-repeat;

}

JSP JSP

<td class="datebox" valign="top"> <Table>......</Table> </td>

When I view in FF, it displays fine. 当我在FF中查看时,它显示正常。 But in IE, the image is not filled completed in the cell. 但是在IE中,图像未完全填充到单元格中。

Thanks a lot for your help in advance. 非常感谢您的提前帮助。

The cell won't automatically resize to the size of its background image. 单元格不会自动调整为背景图片的大小。 In order to make sure that the cell is the same size as the image, apply the image's dimensions to your .datebox , for example 为了确保单元格与图像的大小相同,请将图像的尺寸应用于.datebox ,例如

.datebox {
    width: 100px;
    height: 70px;
}

IE8及以下版本实际上不支持背景大小-请参阅MSDN的IE 兼容性表

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM