要使一整张背景图片自适应 div 或者 table 的大小,可以通过以下 CSS 来实现:
在页面代码中:
```html
```
样式部分:
```css
.bgImage {
width: 100%; /* 必须明确指定 div 的宽度 */
height: 100%;
background: url(背景图路径) no-repeat center center;
background-size: cover; /* 让背景图片填充整个 div 区域,自适应宽高 */
}
```
或者也可以这样:
```css
.bgImage {
width: 100%; /* 明确指定 div 的宽度 */
height: 100%;
background: url(背景图路径) no-repeat center center;
background-size: contain; /* 让背景图片尽可能完整地适应 div 区域,可能会有部分裁剪 */
}
```
这样设置后,背景图片就会根据对应的 div 或 table 的大小自动调整大小,以适应页面布局