Float:right specified for a div inside a table cell does not seem to have any effect in IE. I also tried aligning the text, among other things, to align the contents of the layer to the right, but without success in IE 7.
CSS snippet:
.workloadcell { background-color: #E6D7E9; padding: 0px; width: 14px; height: 16px; text-align: right; } div.workload { background-color: #E6D7E9; text-align: right; width: 14px; float: right; }
HTML snippet:
<td class="workloadcell"> <div class="workload"> 1 </div> </td>
Both HTML and CSS are validated, and in Firefox, the text aligns to the right, as it should. If you want to test the full code by copying it / paste it here:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"> <title>Table Test</title> <style type="text/css"> td { border: 1px solid black; } .workloadcell { background-color: #E6D7E9; padding: 0px; width: 14px; height: 16px; text-align: right; } div.workload { background-color: #E6D7E9; text-align: right; width: 14px; float: right; } </style> </head> <body> <table> <tr> <td> </td> <td colspan="4"> <div> 2008 </div> </td> </tr> <tr> <td> </td> <td> <div> Q1 </div> </td> <td> <div> Q2 </div> </td> <td> <div> Q3 </div> </td> <td> <div> Q4 </div> </td> </tr> <tr> <td> workload forecast </td> <td class="workloadcell"> <div class="workload"> 1 </div> </td> <td class="workloadcell"> <div class="workload"> 2 </div> </td> <td class="workloadcell"> <div class="workload"> 2 </div> </td> <td class="workloadcell"> <div class="workload"> 2 </div> </td> </tr> <tr> <td> actual workload </td> <td class="workloadcell"> <div class="workload"> 3 </div> </td> <td class="workloadcell"> <div class="workload"> 3 </div> </td> <td class="workloadcell"> <div class="workload"> 2 </div> </td> <td class="workloadcell"> <div class="workload"> 3 </div> </td> </tr> </table> </body> </html>
(I know that CSS is not optimal in the sense that class declarations are repeated for multiple elements, but please do not comment on this if this is not the case.)
simon source share