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
<
Spent two days on this problem, finally found the answer here:
You need to set:
background-attachment: fixed;
Not sure why the mods are deleting this answer, its not on the page.
I'd recommend to set the background-image for the table-cells directly, shifting the background-position of all subsequent cells to the left so that it looks as it should. This way you don't have to slice your background-image.
Here's my jQuery solution. It's for a thead tr but should work for tbody tr's as well.
$(document).ready(function () {
// Apply <thead><tr> background row fix for Chrome/Safari (webkit)
if ($.browser.webkit) {
$('thead tr').each(function (i) {
var theadWidth = $(this).width()-1;
$(this).append('<div style="position:absolute;top:'+$(this).position().top+'px;left:'+$(this).position().left+'px;z-index:0;width:'+theadWidth+'px;height:'+($(this).height()+8)+'px;background:#2e4b83 url(th_background.jpg) no-repeat 0 0;background-size:'+theadWidth+'px 100%;"></div>');
});
}
});
You can check it out in Chrome/Firefox/IE9. It should appear the same.
This is the only solution I am aware of without using JavaScript. It has the shortcoming of you specifying the height of the TR and the TD, because the TR is positioned absolute. I am also not sure how it will behave in other browsers.
<style>
tr {
position: absolute;
background: url(http://www.google.com/intl/en_ALL/images/logo.gif) no-repeat;
height: 200px;
border: 1px solid #00f;
}
td {
width: 200px;
height: 200px;
border: 1px solid #f00;
}
</style>
<table cellpadding="0" cellspacing="0">
<tr>
<td></td>
<td></td>
</tr>
</table>
It should fix the tr
background for Chrome and FF:
table.header_table tr#row_1 {
display:flex;
}