How to create <td>
with 2 colors?
This is my code :
<table cellspacing=0>
<tr>
<td bgcolor=green><img src='pic/s.gif' width=8 height=5></td>
<td bgcolor=#AAAAAA><img src='pic/s.gif' width=72 height=5></td>
<td style="color: green;">10%</td>
</tr>
</table>
but I want use one td
and write 10% on td
with z-index=1
but I don't know how.
Select the cell or range of cells you want to format. Click Home > Format Cells dialog launcher, or press Ctrl+Shift+F. On the Fill tab, under Background Color, pick the color you want. To use a pattern with two colors, pick a color in the Pattern Color box, and then pick a pattern in the Pattern Style box.
In HTML, table background color is defined using Cascading Style Sheets (CSS). Specifically, you use the background-color property to define background color. You can apply this property against the whole table, a row, or a single cell.
Cell background colors are set by applying the bgcolor attribute to a <tr> tag (to color the row) or to a <td> tag (to color the cell). Cell colors override row colors which, in turn, override table background colors.
Interesting concept, but do you really need a table layout?
Here's a FIDDLE with a slightly different approach.
HTML
<table>
<tr><td>
<div class='celldiv'>20%
<div class='variablediv'></div>
</div>
</td></tr>
</table>
CSS
td {
height: 20px;
width: 100px;
padding-left: 30px;
}
.celldiv {
height: 100%;
width: 100%;
background-color: red;
}
.variablediv {
float: left;
height: 100%;
width: 20%;
background-color: blue;
margin-right: 5px;
}
And you can dynamically change the width of the blue and the number with jQuery.
Just an idea.
I hope you are expecting the result like this...
DEMO JsFiddle
HTML
<table>
<tr>
<td class="red"></td>
<td class="green"><span class="ten">10%</span></td>
</tr>
</table>
CSS
table
{
border-collapse: collapse;
}
.red
{
background-color: red;
width: 10px;
height: 5px;
}
.green
{
background-color: green;
width: 90px;
height: 5px;
}
.ten
{
color: #ffffff;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With