Tailwind CSS 邊框厚度

2022-08-08 10:24 更新

邊框厚度

用于控制元素邊框?qū)挾鹊墓δ茴悺?/p>

Class
Properties
border-0 border-width: 0px;
border-2 border-width: 2px;
border-4 border-width: 4px;
border-8 border-width: 8px;
border border-width: 1px;
border-t-0 border-top-width: 0px;
border-t-2 border-top-width: 2px;
border-t-4 border-top-width: 4px;
border-t-8 border-top-width: 8px;
border-t border-top-width: 1px;
border-r-0 border-right-width: 0px;
border-r-2 border-right-width: 2px;
border-r-4 border-right-width: 4px;
border-r-8 border-right-width: 8px;
border-r border-right-width: 1px;
border-b-0 border-bottom-width: 0px;
border-b-2 border-bottom-width: 2px;
border-b-4 border-bottom-width: 4px;
border-b-8 border-bottom-width: 8px;
border-b border-bottom-width: 1px;
border-l-0 border-left-width: 0px;
border-l-2 border-left-width: 2px;
border-l-4 border-left-width: 4px;
border-l-8 border-left-width: 8px;
border-l border-left-width: 1px;

所有邊

使用 ?border?, ?.border-0?, ?.border-2?, ?.border-4?, 或 ?.border-8? 等功能類來設(shè)置一個元素所有邊框的寬度。


<div class="border-0 border-indigo-600 ..."></div>
<div class="border border-indigo-600 ..."></div>
<div class="border-2 border-indigo-600 ..."></div>
<div class="border-4 border-indigo-600 ..."></div>
<div class="border-8 border-indigo-600 ..."></div>

單獨的邊

使用 ?border-{side}?, ?.border-{side}-0?, ?.border-{side}-2?, ?.border-{side}-4?, 或 ?.border-{side}-8? 等功能類來設(shè)置元素一側(cè)的邊框?qū)挾取?/p>


<div class="border-t-2 border-fuchsia-600 ..."></div>
<div class="border-r-2 border-fuchsia-600 ..."></div>
<div class="border-b-2 border-fuchsia-600 ..."></div>
<div class="border-l-2 border-fuchsia-600 ..."></div>

元素間

您還可以使用 ?divid-{x/y}-{width}? 和 ?divid-{color}? 功能類在子元素之間添加邊框。

<div class="divide-y divide-light-blue-400 ...">
  <div>1</div>
  <div>2</div>
  <div>3</div>
  <div></div>
</div>

響應(yīng)式

要在特定的斷點處控制元素的邊框?qū)挾?,請在任何現(xiàn)有的邊框?qū)挾裙δ茴愔刑砑?nbsp;?{screen}:? 前綴。例如,使用 ?md:border-t-4? 來應(yīng)用 ?border-t-4? 功能類,只適用于中等尺寸以上的屏幕。

<div class="border-2 md:border-t-4 ..."></div>

關(guān)于 Tailwind 的響應(yīng)式設(shè)計功能的更多信息,請查看響應(yīng)式設(shè)計文檔。

自定義

變體

默認(rèn)情況下, 針對 border width 功能類,只生成 responsive 變體。

您可以通過修改您的 ?tailwind.config.js? 文件中的 ?variants ?部分中的 ?borderWidth ?屬性來控制為 border width 功能生成哪些變體。

例如,這個配置也將生成 hover and focus 變體:

  // tailwind.config.js
  module.exports = {
    variants: {
      extend: {
        // ...
       borderWidth: ['hover', 'focus'],
      }
    }
  }

禁用

如果您不打算在您的項目中使用 border width 功能,您可以通過在配置文件的 ?corePlugins ?部分將 ?borderWidth ?屬性設(shè)置為 ?false ?來完全禁用它們:

  // tailwind.config.js
  module.exports = {
    corePlugins: {
      // ...
     borderWidth: false,
    }
  }


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號