[英]Tailwindcss - How to use .class selector?
我正在從 Ant 設計(使用 LESS)切換到使用 Tailwindcss。 總體而言,Tailwindcss 很好用,但我注意到其中存在一些問題。
在 LESS 中,通過定位 css 類名並使用.class
選擇器修改其 css 來覆蓋 styles 更容易。
例如,此代碼段用於覆蓋ql-container
和ql-toolbar
上的 styles。
.container {
[class*="ql-container"] {
min-height: 100px;
max-height: 200px;
overflow-y: auto;
border-bottom-left-radius: 6px;
border-bottom-right-radius: 6px;
}
[class*='ql-toolbar'] {
border-top-left-radius: 6px;
border-top-right-radius: 6px;
}
}
但是,我怎樣才能在 Tailwindcss 中做同樣的事情? 可行嗎? 或者我應該堅持使用 LESS 甚至純 CSS 來實現這種行為?
tailwind.css
類的基礎實現, tailwind.config.css
是你要做的地方。 tailwind.config.css
中的示例代碼:
module.exports = {
content: ['./src/**/*.{html,js}'],
theme: {
colors: {
'blue': '#1fb6ff',
'purple': '#7e5bef',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
'yellow': '#ffc82c',
'gray-dark': '#273444',
'gray': '#8492a6',
'gray-light': '#d3dce6',
},
fontFamily: {
sans: ['Graphik', 'sans-serif'],
serif: ['Merriweather', 'serif'],
},
extend: {
spacing: {
'8xl': '96rem',
'9xl': '128rem',
},
borderRadius: {
'4xl': '2rem',
}
}
},
}
示例:如果您希望text-8xl
在其初始 class 實現不受影響的情況下添加下划線。 基數變化base.css
class
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
[class~="text-8xl"] {
@apply text-8xl underline; 👈 text-8xl now has underline aswell
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.