CSS 属性

逻辑块边框的宽度由 CSS 属性 border-block-width 定义,该属性根据元素的书写模式、方向性和文本方向映射到物理边框宽度。

属性值

语法

border-block-width = <'border-top-width'>{1,2} 

适用范围

所有 HTML 元素。

CSS border-block-width: thin

以下示例演示了 border-block-width 属性与thin值的用法。

<html>
<head>
<style>
   body {
      font-family: 'Arial', sans-serif;
      margin: 50px;
      padding: 50px;
      background-color: #f0f0f0;
   }
   .new-container {
      background-color: #f0e8e6;
      width: 400px;
      height: 400px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 15px;
      box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.8);
   }
   .custom-border {
      border: 4px dashed #e74c3c;
      border-block-width: thin;
      padding: 15px;
      margin: 10px;
      font-size: 22px;
      font-weight: bold;
      color: #333;
   }
</style>
</head>
<body>
<div class="new-container">
<p class="custom-border">带有thin样式的 border-block-width 属性的示例</p>
</div>
</body>
</html> 

CSS border-block-width: medium

以下示例演示了 border-block-width 属性和medium值的用法。

<html>
<head>
<style>
   body {
      font-family: 'Arial', sans-serif;
      margin: 50px;
      padding: 50px;
      background-color: #f0f0f0;
   }
   .new-container {
      background-color: #ebad9b;
      width: 400px;
      height: 400px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 15px;
      box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.8);
   }
   .custom-border {
      border: 4px dashed #b5401d;
      border-block-width: medium;
      padding: 15px;
      margin: 10px;
      font-size: 22px;
      font-weight: bold;
      color: #333;
   }
</style>
</head>
<body>
<div class="new-container">
<p class="custom-border">带有medium样式的 border-block-width 属性的示例</p>
</div>
</body>
</html> 

CSS border-block-width: thick

以下示例演示了 border-block-width 属性和thick值的用法

<html>
<head>
<style>
   body {
      font-family: 'Arial', sans-serif;
      margin: 50px;
      padding: 50px;
      background-color: #f0f0f0;
   }
   .new-container {
      background-color: #ced7f0;
      width: 400px;
      height: 400px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 15px;
      box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.8);
   }
   .custom-border {
      border: 2px dashed #134ef0;
      border-block-width: thick;
      padding: 15px;
      margin: 10px;
      font-size: 22px;
      font-weight: bold;
      color: #333;
   }
</style>
</head>
<body>
<div class="new-container">
<p class="custom-border">带有thick样式的 border-block-width 属性的示例</p>
</div>
</body>
</html> 

CSS border-block-width: length 值

以下示例演示了 border-block-width 属性和长度值的用法.

<html>
<head>
<style>
   body {
      font-family: 'Arial', sans-serif;
      margin: 50px;
      padding: 50px;
      background-color: #f0f0f0;
   }
   .new-container {
      background-color: #f5f3e1;
      width: 400px;
      height: 400px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 15px;
      box-shadow: 4px 4px 12px rgba(0, 0, 0, 0.8);
   }
   .custom-border {
      border: 2px solid #9c9105;
      border-block-width: 5px 10px;
      padding: 15px;
      margin: 10px;
      font-size: 20x;
      font-weight: bold;
      color: #333;
   }
</style>
</head>
<body>
<div class="new-container">
<p class="custom-border">带有 border-block-width 属性的示例。</p>
</div>
</body>
</html> 

CSS border-block-width: 书写模式

以下示例演示了在垂直书写模式下使用 border-block-style 属性。

<html>
<head>
<style>
   .custom-div {
      background-color: gray;
      width: 450px;
      height: 350px;
   }
   .demo-border {
      writing-mode: vertical-rl;
      border: 1px solid blue;
      border-block-width: 5px; 
      padding: 15px;
      margin: 10px;
      color: #fff;
      font-size: 22px;
   }
</style>
</head>
<body>
<div class="custom-div">
<p class="demo-border">这是一个带有 border-block-width 属性的示例。</p>
</div>
</body>
</html>