首页 > 文章列表 > 如何在等宽字体中显示字符串?

如何在等宽字体中显示字符串?

467 2023-09-12

使用JavaScript的fixed()方法以固定间距字体显示,就像在标签中一样。

示例

您可以尝试运行以下命令以固定间距字体显示字符串的代码。

<html>
   <head>
      <title>JavaScript String fixed() Method</title>
   </head>

   <body>
      <script>
         var str = new String("Hello world");
         alert(str.fixed());
      </script>
   </body>
</html>