简体   繁体   中英

Positioning and aligning HTML text

How can I write HTML code to produce output like this:

Calculation 1: 2

Calculation 2: 2

Calculation 3: 2

Total: 8

However I need all the numbers to be aligned ^ about here in the page

Tables will do the trick!

See fiddle https://jsfiddle.net/DIRTY_SMITH/rupbwpx0/1/

  <table style="width:50%">
  <tr>
    <td>Calculation 1:</td>
    <td>2</td>
  </tr>
  <tr>
    <td>Calculation 2:</td>
    <td>2</td>
  </tr>
  <tr>
    <td>Calculation 3:</td>
    <td>2</td>
  </tr>
  <tr>
    <td>Total</td>
    <td>8</td>
  </tr>
</table>

HTML is for markup and if you want to layout, then use CSS. The following HTML code will show exactly what you are looking for and it could be also styled with CSS.

 <div class="main"> <span>Calculation 1:</span> <span>2</span> </div> <div class="main"> <span>Calculation 2:</span> <span>2</span> </div> <div class="main"> <span>Calculation 3:</span> <span>2</span> </div> <div class="main"> <span>Total:</span> <span>8</span> </div> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM