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