首頁  >  文章  >  web前端  >  如何在等寬字體中顯示字串?

如何在等寬字體中顯示字串?

王林
王林轉載
2023-09-16 12:25:061098瀏覽

如何在等寬字體中顯示字串?

使用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>

以上是如何在等寬字體中顯示字串?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除