I\'m trying to set a background-image to a table row, but background is applied to all its td children.
In IE7 there is the same bug but it is solve with
<
Chrome (WebKit) overrides the position:relative for table rows and calculates the style to static. Bug or feature - this prevents the position:relative fix as is used in IE7.
Solution when using fixed (known) cell sizes: tr { float:left; }
And add appropriate cell sizes to all cells in the table (either via class or inline styles). I had also added row sizes, however it might not be required for the solution to work.
I have no need for a solution for dynamic cell sizes, so I haven't been exploring that usecase.
What I ended up doing was:
table.money-list tr {
background: url(images/status-2.gif) no-repeat;
}
@media screen and (-webkit-min-device-pixel-ratio:0) {
/*Chrome CSS here*/
table tbody tr td:first-child {
background-image: none;
background-color: transparent;
}
table tr td{
background-color: #FFFFFF;
}
}
So as you can see, just set a background color to every TD but the first one, and target Webkit.
This works for me in all browsers:
tr {
background: transparent url(/shadow-down.gif) no-repeat 0% 100%;
display: block;
position: relative;
width: 828px;
}
tr td{
background: transparent;
}
try to add:
td{white-space: nowrap}
Can help in some situation.
In tr style tag include Style='Display:inline-table;'
It works fine in all browser.
None of the workarounds mentioned worked for me quite right. Here's what I ended up with:
TABLE TBODY.highlight {
background-image: url(path/image.png);
}
TABLE>* {
float: left;
clear: both;
}
Only tested in Chrome and Firefox so no idea how it works in IE (not important in my case), but for me this works flawlessly!