Reputation: 3149
I'd like to set the background of a table row. The background can be an image or CSS (preferably). I want it to look something like this, with opacity of the background:
I've tried it using a repeating image. Here is the image I'm using.
but it looks like this for some reason:
My HTML looks like this:
<table id="chPurchaseTable">
<thead>
<tr>
<th>Quantity</th>
<th>Product</th>
<th>u/m</th>
<th>Price Each</th>
<th>Line Total</th>
<th></th>
</tr>
</thead>
<tbody>
and my CSS
#chPurchaseTable thead tr{
background:url('../images/rarrows.png') repeat;
}
How can I achieve this affect?
Upvotes: 1
Views: 76
Reputation:
You need to make use of:
background: url('https://i.sstatic.net/jT3CO.png') repeat;
background-size: contain; /*To make sure the entire image fits the container */
#chPurchaseTable thead tr {
background: url('https://i.sstatic.net/jT3CO.png') repeat;
background-size: contain;
color: white;
}
<table id="chPurchaseTable">
<thead>
<tr>
<th>Quantity</th>
<th>Product</th>
<th>u/m</th>
<th>Price Each</th>
<th>Line Total</th>
<th></th>
</tr>
</thead>
<tbody>
To make the background transparent like you require, apply the background on a psuedoelement with opacity instead of on the actual tr:
#chPurchaseTable thead tr {
color: red;
position: relative;
}
#chPurchaseTable thead tr::before {
content: '';
width: 100%;
height: 100%;
background: url('https://i.sstatic.net/jT3CO.png') repeat;
background-size: contain;
opacity: 0.5;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
<table id="chPurchaseTable">
<thead>
<tr>
<th>Quantity</th>
<th>Product</th>
<th>u/m</th>
<th>Price Each</th>
<th>Line Total</th>
<th></th>
</tr>
</thead>
<tbody>
Upvotes: 3