You can use the following selector without using additional classes:
td span:last-child{ color:green; float:right; }
Demo: http://jsfiddle.net/QR3kP/1/
For compatibility with IE7 and above, use the CSS code below:
td span{ float:right; } td span:first-child{ float:left; }
Demo: http://jsfiddle.net/QR3kP/4/
Another approach is to align the text inside the <td> and float with only the first <span> :
td { text-align:right } td span:first-child { float:left; }
Demo: http://jsfiddle.net/QR3kP/29/
You can use a similar method with the above using even less css declarations:
td span:first-child + span { float:right; }
In the above example, the text alignment by default td remains, and you select only one brother, which immediately precedes after the first span . Then you just float right. Of course, you can use the ~ selector, which is the same in this case .
Demo: http://jsfiddle.net/QR3kP/32/
See the compatibility chart here: http://kimblim.dk/css-tests/selectors/
See the CSS selector here: http://www.w3.org/TR/CSS2/selector.html
otinanai
source share