css - 如何用图像填充单元格

标签 css

您好我正在使用 3px*10px 渐变图像来填充我想用这个图像填充完整的单元格并且我还想在单元格的内容增加时自动拉伸(stretch)图像..但是我不想要它重复,因为图像是渐变的,它看起来很难看。有人可以帮忙吗。

代码片段如下。

<html>
<head></head>
<body>
<table border=1>
<tr><td>a<td rowspan="9" style="background-image:url('images/bg_menu_hov.gif');background-repeat:no-repeat; height:100%;">&nbsp<td>b</tr>
<tr><td>c<td>d</tr>
<tr><td>e<td>f</tr>
<tr><td>c<td>d</tr>
<tr><td>e<td>f</tr>
<tr><td>c<td>d</tr>
<tr><td>e<td>f</tr>
<tr><td>c<td>d</tr>
<tr><td>e<td>f</tr>
</table>
<body>
</html>

最佳答案

根据图像,您需要设置 background-repeat不同。

拉伸(stretch)图像可能不是一个好主意。通常,您应该使渐变宽度或高度足以适合您的设计。将渐变淡化为与您设置的背景颜色相同的颜色是个好主意。

从您的图像大小 (3px*10px) 来看,我猜您需要将 background-repeat 设置为 'repeat-x'。

关于css - 如何用图像填充单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4947732/

相关文章:

css - 像鸡蛋一样的悬停效果

html - 高度 :100% problem in IE7, 不在 FF 中

html - div 中的图像不正确

css - Bootstrap 和搜索输入宽度随焦点变化

javascript - 如何实现div block 高度的动态计算?

javascript - JQuery.css ("display") = "block"不工作

javascript - 如何用jquery改变输入按钮的背景图片

html - 在底部设置页脚,但并不总是在底部

jquery - IE7中的HTML布局问题

html - 通过 CSS 访问 Style 属性