HTML + CSS短標題(二,三,四文字長度)兩端對齊的方式


今天切圖碰到了一個看似好弄,卻並不好弄的文本兩端對齊問題。如圖1-1

圖1-1

我的方案

1.使用"SimSun"字體,直接打空格或者 。

比如:demo.html

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
      *{margin:0;padding:0;}
      div{width:500px;height:300px;margin:100px auto;}
      th{font-family:"SimSun";}
</style>
</head>
<body>
<div>
  <table>
    <tr>
      <th>&nbsp;&nbsp;名:</th>
      <td></td>
    </tr>
    <tr>
      <th>&nbsp;&nbsp;&nbsp;&nbsp;稱:</th>
      <td></td>
    </tr>
    <tr>
      <th>&nbsp;&nbsp;&nbsp;&nbsp;碼:</th>
      <td></td>
    </tr>
    <tr>
      <th>&nbsp;&nbsp;碼:</th>
      <td></td>
    </tr>
    <tr>
      <th>&nbsp;&nbsp;注:</th>
      <td></td>
    </tr>
  </table>
</div>
</body>
</html>

 

這里用&nbsp是為了顯眼……

 

1.2 不用字體全角空格也可以~

1.3 text-align:justify;

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM