Html 表格标题背景图像不显示';不能在CSS文件中工作
为什么背景图像属性不能从CSS文件中工作,但如果我在表格的“th”标记中的“style”中使用它,它就会工作Html 表格标题背景图像不显示';不能在CSS文件中工作,html,css,html-table,Html,Css,Html Table,为什么背景图像属性不能从CSS文件中工作,但如果我在表格的“th”标记中的“style”中使用它,它就会工作 table .header { background-image: url('Images/bg.png'); background-repeat: no-repeat; border-left: 1px solid #FFF; border-right: 1px solid #000; border-top: 1px solid #FFF; pad
table .header {
background-image: url('Images/bg.png');
background-repeat: no-repeat;
border-left: 1px solid #FFF;
border-right: 1px solid #000;
border-top: 1px solid #FFF;
padding-left: 30px;
padding-top: 8px;
height: auto;
}
编辑:我的示例表:
<table id="exampletable" class="tablesorter">
<thead>
<tr>
<th>head1</th>
<th>heade2</th>
</tr>
</thead>
<tbody>
<tr>
<td>body1</td>
<td>body2</td>
</tr>
<tr>
<td>body3</td>
<td>body4</td>
</tr>
</tbody>
</table>
标题1
头2
车身1
车身2
车身3
车身4
我在site.master中链接了css文件(我在asp web app中)在图像之前添加
。/
table .header {
background-image: url('../Images/bg.png');
background-repeat: no-repeat;
border-left: 1px solid #FFF;
border-right: 1px solid #000;
border-top: 1px solid #FFF;
padding-left: 30px;
padding-top: 8px;
height: auto;
}
如果图像
和内容
并排在文件夹中则“header”是表的类吗?在这种情况下,css中它们之间将没有空格:
table.header {
...
}
假设这是您的表,
是您的标题
<table border="1">
<th>Column 1</th>
<tr>
<td>Value 1</td>
</tr>
</table>
请参见您可以给它一个类似于我的示例中的类,然后调用您的css
<table id="exampletable" class="tablesorter">
<thead class="sample">
<tr>
<th>head1</th>
<th>heade2</th>
</tr>
</thead>
<tbody>
<tr>
<td>body1</td>
<td>body2</td>
</tr>
<tr>
<td>body3</td>
<td>body4</td>
</tr>
</tbody>
</table>
.sample {
background-image: url('Images/bg.png');
background-repeat: no-repeat;
border-left: 1px solid #FFF;
border-right: 1px solid #000;
border-top: 1px solid #FFF;
padding-left: 30px;
padding-top: 8px;
height: auto;
}
标题1
头2
车身1
车身2
车身3
车身4
.样品{
背景图片:url('Images/bg.png');
背景重复:无重复;
左边框:1px实心#FFF;
右边框:1px实心#000;
边框顶部:1px实心#FFF;
左侧填充:30px;
填充顶部:8px;
高度:自动;
}
您是如何链接css
文件的?
图像路径应与css的位置相对应。请仅显示您设计的表格和标题部分检查图像路径,在这种情况下是否正确,但是,您可以通过调试来检查映像是否正在加载或未尝试:/Images/bg.png
和~/Images/bg.png
,但仍然不起作用
<table id="exampletable" class="tablesorter">
<thead class="sample">
<tr>
<th>head1</th>
<th>heade2</th>
</tr>
</thead>
<tbody>
<tr>
<td>body1</td>
<td>body2</td>
</tr>
<tr>
<td>body3</td>
<td>body4</td>
</tr>
</tbody>
</table>
.sample {
background-image: url('Images/bg.png');
background-repeat: no-repeat;
border-left: 1px solid #FFF;
border-right: 1px solid #000;
border-top: 1px solid #FFF;
padding-left: 30px;
padding-top: 8px;
height: auto;
}