tailwindCss學(xué)習(xí)記錄

tailwindcss

  • 定制:可以通過(guò)tailwind.config.js配置修改默認(rèn)值 參考

布局

名稱(chēng) 作用
container 定義元素寬度
columns-{x} 定義容器中的子元素的列數(shù)
box-border 定義容器是否包含邊框尺寸
display 定義容器的屬性,參考下面display表格
float 定義原始浮動(dòng)方向
clear 定義容器文字緊密布局方式,有清除浮動(dòng)的效果
object fit 定義圖片延伸方式,有點(diǎn)類(lèi)似于小程序中的mode 屬性效果參考下面object-fit表格
object position object 的延伸,效果與小程序mode一致,控制顯示元素的方向
overflow 控制溢出顯示效果,參考下面overflow表格
position 定位
top/right/bottom/left 定位數(shù)值
visibility 控制元素可見(jiàn)度
z-index z軸的排序

**display **

作用
flex flex布局
inline-flex 創(chuàng)建一個(gè)跟隨文本流的flex盒子,可以理解成把一個(gè)塊元素變成行內(nèi)元素
block 塊元素
lnline 行元素
grid 宮格元素
lnline-grid 行級(jí)宮格元素,參考Display - TailwindCSS中文文檔 | TailwindCSS中文網(wǎng)
table 表格元素
hidden \none 刪除元素

object fit

效果
object-contain 占滿(mǎn)盒子,等比例放大
object-cover 覆蓋盒子,圖片不會(huì)變形
object-fill 拉伸
object-none 無(wú)效果
object-scale-down 縮小

overflow

效果
overflow-x-hidden x軸溢出隱藏、y軸同理
overflow-visible 溢出依然顯示
overflow-auto 溢出出現(xiàn)滾動(dòng)條,不溢出不會(huì)出現(xiàn)
overflow-scroll 無(wú)論溢不溢出都會(huì)出現(xiàn)滾動(dòng)條

flexbox& grid

名稱(chēng) 作用 寫(xiě)法
basis 定義flex項(xiàng)目初始值大小 basis-1、basis-1/4、md:basis-1
direction 定義flex容器排序方向 flex-row、flex-row-reverse、flex-col、flex-col-reverse
weap 定義flex容器是否換行子項(xiàng)目 flex-wrap、flex-nowrap、flex-wrap-reverse
flex flex項(xiàng)目的占比簡(jiǎn)寫(xiě) flex-1、flex-auto、flex-initial、flex-noe
shrink flex項(xiàng)目的縮小比例
order flex項(xiàng)目的排序 order-1、order-1/4、md:order-1、order-first、order-last
grid-cols grid列的數(shù)量 grid-cols-1
col-span grid項(xiàng)目的跨列數(shù)量 col-span–1、col-start-1、col-span-full
grid-row grid行的數(shù)量 grid-rows-1
row-span grid項(xiàng)目的跨行數(shù)量 row-span–1、row-start-1、row-span-full
grid auto flow 定義grid容器項(xiàng)目的放置方法
gap grid間隔 gap-1、gap-x-1、gap-y-1、gap-x-1px
justify content 定義flex容器主軸對(duì)齊方式 justify-start
justify items 定義flex容器項(xiàng)目的統(tǒng)一對(duì)齊方式 justify-items-center
justify self 單獨(dú)定義flex項(xiàng)目元素的對(duì)齊方式 justify-self-center
align content 定義flex容器交叉軸對(duì)齊方式 content-center
align Items 定義flex容器交叉軸單個(gè)項(xiàng)目的對(duì)齊方式 items-start
align self 單獨(dú)定義flex容器項(xiàng)目交叉軸的對(duì)齊方式
place content grid項(xiàng)目的對(duì)齊方式,簡(jiǎn)寫(xiě),分別是主軸-交叉軸的對(duì)齊定義 place-content-center

間隔(與windicss寫(xiě)法和用法都一致)

padding、margin、space between

尺寸 (與windicss寫(xiě)法和用法都一致)

width、min-width、max-width、height、min-height、max-height

排版 (與windicss寫(xiě)法和用法都一致)

名稱(chēng) 作用
font-family 定義字體
font size 定義字體大小
font smoothing 定義字體平滑程度
font weight 定義字體粗細(xì)
font variant numeric 定義數(shù)字間隔大小統(tǒng)一
letter spacing 定義單詞間隔
line clamp 定義文字行數(shù)
line height 文字行高
list style image 自定義列表序號(hào)圖片
list style position 自定義列表序號(hào)間隔
list style type 自定義序號(hào)類(lèi)型
text align 文字對(duì)齊方式
text color 文字顏色
text decoration 文字下劃線樣式
text decoration color 下劃線顏色
text decoration style 下劃線樣式
text decoration thickness 下劃線厚度
text transform 文字大小寫(xiě)相關(guān)樣式,可轉(zhuǎn)換成單詞首字母大寫(xiě)
text Overflow 文字溢出設(shè)置
text indent 文本縮進(jìn)
vertical align 文本縱向?qū)R方式
Whitespace 定義文本空白字符顯示方式
Word Break 定義文本分詞方式
content 定義元素偽元素的內(nèi)容配合::before ::after使用

背景 (與windicss寫(xiě)法一致)

名稱(chēng) 描述
attachment 用于控制背景圖像在滾動(dòng)時(shí)的行為方式、可控制固定位置不跟隨滾動(dòng)條滾動(dòng)而滾動(dòng)
clip 控制元素背景邊界框
origin 控制元素背景相對(duì)于邊框、填充和內(nèi)容的定位方式
position 背景定位
repeat 背景重復(fù)定義
Gradient Color Stops 漸變背景

邊框與輪廓(與windicss寫(xiě)法一致)

輪廓邊框之外

effects 控制容器陰影

filters 濾鏡

名稱(chēng) 描述
blur 模糊
brightness 亮度
contrast 對(duì)比度
drop-shadow 陰影
grayscale 灰度
hue rotate 詭異的濾鏡
Invert 底片
Backdrop Blur 背景模糊濾鏡應(yīng)用于元素

transitions 、animation 過(guò)渡效果與動(dòng)畫(huà) (與windicss寫(xiě)法一致)

transforms 變形

名稱(chēng) 描述
scale 縮放
rotate 旋轉(zhuǎn)
translate 位移
skew 傾斜
transform origin 旋轉(zhuǎn),定義旋轉(zhuǎn)的原點(diǎn)

Interactivity 互動(dòng) (與windicss寫(xiě)法一致)

定義一些用戶(hù)事件,如鼠標(biāo)形狀、選中顏色、輸入框選中顏色、滾動(dòng)條樣式、

svg

名稱(chēng) 描述
fill 定義svg fill屬性的值,用于定義svg圖片的顏色
Stroke Width 定義svg線條寬度

鼠標(biāo)懸停狀態(tài)

:hover 鼠標(biāo)移入時(shí)
:focus 鼠標(biāo)點(diǎn)擊時(shí)
:active 獲得焦點(diǎn)時(shí)
:visited 選中過(guò)的

偽元素

::before
:after

偽類(lèi)

名稱(chēng) 描述
last: 最后一個(gè)子元素
only :only-child 只有一個(gè)子元素時(shí)
odd: 奇數(shù)
even: 偶數(shù)
empty: 內(nèi)容為空時(shí)
disabled: 不可選中的
enabled: 啟用的
checked: 選中的

響應(yīng)式

sm:
md:
lg:
xl:
2xl:

主題 默認(rèn)亮色主題

dark:

使用修飾符

<li class="[&:nth-child(3)]:underline">{item}</li> // 設(shè)置第三個(gè)子元素的樣式
<li class="lg:[&:nth-child(3)]:hover:underline">{item}</li> // 設(shè)置lg 下 第三個(gè)子元素鼠標(biāo)移入時(shí)樣式
<div class="[&_p]:mt-4"> // 設(shè)置所有p標(biāo)簽的marig top值
<div class="lg:content-auto"> //  使用預(yù)定義變量 content-auto

修飾符大全

Modifier CSS
hover &:hover
focus &:focus
focus-within &:focus-within
focus-visible &:focus-visible
active &:active
visited &:visited
target &:target
first &:first-child
last &:last-child
only &:only-child
odd &:nth-child(odd)
even &:nth-child(even)
first-of-type &:first-of-type
last-of-type &:last-of-type
only-of-type &:only-of-type
empty &:empty
disabled &:disabled
enabled &:enabled
checked &:checked
indeterminate &:indeterminate
default &:default
required &:required
valid &:valid
invalid &:invalid
in-range &:in-range
out-of-range &:out-of-range
placeholder-shown &:placeholder-shown
autofill &:autofill
read-only &:read-only
before &::before
after &::after
first-letter &::first-letter
first-line &::first-line
marker &::marker
selection &::selection
file &::file-selector-button
backdrop &::backdrop
placeholder &::placeholder
sm @media (min-width: 640px)
md @media (min-width: 768px)
lg @media (min-width: 1024px)
xl @media (min-width: 1280px)
2xl @media (min-width: 1536px)
[min-…] @media (min-width: …)
max-sm @media not all and (min-width: 640px)
max-md @media not all and (min-width: 768px)
max-lg @media not all and (min-width: 1024px)
max-xl @media not all and (min-width: 1280px)
max-2xl @media not all and (min-width: 1536px)
[max-…] @media (max-width: …)
dark @media (prefers-color-scheme: dark)
portrait @media (orientation: portrait)
landscape @media (orientation: landscape)
motion-safe @media (prefers-reduced-motion: no-preference)
motion-reduce @media (prefers-reduced-motion: reduce)
contrast-more @media (prefers-contrast: more)
contrast-less @media (prefers-contrast: less)
print @media print
[supports-…] @supports (…)
aria-checked &[aria-checked=“true”]
aria-disabled &[aria-disabled=“true”]
aria-expanded &[aria-expanded=“true”]
aria-hidden &[aria-hidden=“true”]
aria-pressed &[aria-pressed=“true”]
aria-readonly &[aria-readonly=“true”]
aria-required &[aria-required=“true”]
aria-selected &[aria-selected=“true”]
[aria-…] &[aria-…]
[data-…] &[data-…]
rtl [dir=“rtl”] &
ltr [dir=“l(fā)tr”] &
open &[open]
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容