我們如何在 HTML 中顯示元素邊框的厚度?


使用 HTML 中的 border 屬性可以顯示邊框的厚度。

注意 - 此屬性在 HTML5 中不受支援。

示例

可以執行以下程式碼學習如何在 HTML 中實現 border 屬性 -

<!DOCTYPE html>
<html>
   <body>
      <h2>Cricketers</h2>
      <table style="width:100%" border="1">
         <th>Name</th>
         <tr>
            <td>Sachin Tendulkar</td>
         </tr>
         <tr>
            <td>Virat Kohli</td>
         </tr>
      </table>
   </body>
</html>

使用 CSS,因為border 屬性在 HTML5 中已棄用。

<!DOCTYPE html>
<html>
   <head>
      <style>
         table, th, td {
            border: 1px solid black;
         }
      </style>
   </head>
   <body>
      <h2>Cricketers</h2>
      <table style="width:100%">
         <caption>Indian Cricketers</caption>
         <th>Name</th>
         <tr>
            <td>Sachin Tendulkar</td>
         </tr>
         <tr>
            <td>Virat Kohli</td>
         </tr>
      </table>
   </body>
</html>

更新時間:2020-03-02

126 次瀏覽

開啟你的 職業

透過完成該課程獲取認證

入門
廣告
© . All rights reserved.