开发者

alignment using CSS

I need to align a set of rows using style property

This is the HTML code that is being transformed using XSL

<span style="white-space: pre; font-size: 8pt; font-family: Lucida console, Courier ">&lt;40      : item1</span><br>
<sp开发者_StackOverflow中文版an style="white-space: pre; font-size: 8pt; font-family: Lucida console, Courier ">40-80    : item2 </span><br>

What is needed is how to align items like

<40      : item1
40-80    : item2

currently it appears like

<40 : item1
40-80 : item2 

is this possible using style property?

using Internet explorer version 6 & above


There is a char attribute for HTML td tags, however, it is not at all supported as far as I know.

This is valid HTML:

<table>
  <tr char=".">
    <td>11.10</td>
  </tr>
  <tr char=".">
    <td>111.20</td>
  </tr>
  <tr char=".">
    <td>15552.52</td>
  </tr>
</table>

I have used this workaround in the past:

http://krijnhoetmer.nl/stuff/javascript/table-align-char/


use &nbsp; instead of spaces


sure it is possible. u can use

<div style="float: left; width: 50px">&lt; 40</div><div style="float: left; ">:</div><div style="float: left; ">item 1</div>
 <span style='clear: left'></span>
 <div style="float: left; width: 50px"> 40</div><div style="float: left; ">:</div><div style="float: left; ">item 2</div>

or else you could try

display: table-cell;  

it can be put in the styling.


white-space: pre; should do the trick and work in all browsers..

  • do you get this error in every browser or just in IE?
  • are there any other stylesheeds affecting these <span>-elements?
  • is it possible to change the xsl to get another markup?


many options:

If you can wrap range (ex 40-80) and item name (ex item1) in separate element, then define width for each.

Otherwise, specify white-space: pre so that whitespace preserved by the browser. Don't forget to use Monospaced font so that each character each occupy the same amount of horizontal space. example: Consolas, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜