時間:2023-04-21 13:39:02 | 來源:網(wǎng)站運(yùn)營
時間:2023-04-21 13:39:02 來源:網(wǎng)站運(yùn)營
[翻譯]Tailwind CSS v3.0:由于官方文檔是基于mdx渲染的,所以本文樣例采用截圖呈現(xiàn)
上面提到的視頻可以看我發(fā)到B站的中字版本,講得比這個blog要詳細(xì)很多Tailwind CSS v3.0 一定是我們有史以來最激動人心的版本,包括以下改進(jìn):
variants
、支持任意值、更好的瀏覽器性能,等等。npm install -D tailwindcss@latest postcss autoprefixer
...或者前往Tailwind Play,直接在瀏覽器中嘗試最新的功能。variant
配置成為過去式。<button class="bg-cyan-500 **shadow-lg shadow-cyan-500/50** ..."> Subscribe</button><button class="bg-blue-500 **shadow-lg shadow-blue-500/50** ..."> Subscribe</button><button class="bg-indigo-500 **shadow-lg shadow-indigo-500/50** ..."> Subscribe</button>
在陰影顏色文檔中了解更多。<div class="**snap-x** ..."> <div class="snap-center ..."> <img src="https://images.unsplash.com/photo-1604999565976-8913ad2ddb7c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" /> </div> <div class="snap-center ..."> <img src="https://images.unsplash.com/photo-1540206351-d6465b3ac5c1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" /> </div> <div class="snap-center ..."> <img src="https://images.unsplash.com/photo-1622890806166-111d7f6c7c97?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" /> </div> <div class="snap-center ..."> <img src="https://images.unsplash.com/photo-1590523277543-a94d2e4eb00b?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" /> </div> <div class="snap-center ..."> <img src="https://images.unsplash.com/photo-1575424909138-46b05e5919ec?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" /> </div> <div class="snap-center ..."> <img src="https://images.unsplash.com/photo-1559333086-b0a56225a93c?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=320&h=160&q=80" /> </div></div>
從新的滾動邊距工具開始,來了解整個 API。<div class="**columns-1** **sm:columns-3** ..."> <p>...</p> <!-- ... --></div>
在columns文檔中了解更多--也可以查看新的break-after/inside/before實(shí)用工具。accent-color
屬性的支持,以及對文件輸入按鈕樣式的修飾符,使你比以往任何時候都更容易在原生表單控件上發(fā)揮自己的作用。<form> <div class="flex items-center space-x-6"> <div class="shrink-0"> <img class="h-16 w-16 object-cover rounded-full" src="https://images.unsplash.com/photo-1580489944761-15a19d654956?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1361&q=80" alt="Current profile photo" /> </div> <label class="block"> <span class="sr-only">Choose profile photo</span> <input type="file" class="block w-full text-sm text-slate-500 **file:mr-4** **file:py-2** **file:px-4** **file:rounded-full** **file:border-0** **file:text-sm** **file:font-semibold** **file:bg-violet-50** **file:text-violet-700** **hover:file:bg-violet-100** " /> </label> </div> <label class="mt-6 flex items-center justify-center space-x-2 text-sm font-medium text-slate-600" > <input type="checkbox" class="**accent-violet-500**" checked /> <span>Yes, send me all your stupid updates</span> </label></form>
在強(qiáng)調(diào)色和文件輸入按鈕文檔中了解更多。print
修飾符可以讓你決定網(wǎng)站在人們打印時的樣子。<div> <article class="**print:hidden**"> <h1>My Secret Pizza Recipe</h1> <p>This recipe is a secret, and must not be shared with anyone</p> <!-- ... --> </article> <div class="hidden **print:block**"> Are you seriously trying to print this? It's secret! </div></div>
在打印樣式文檔中了解更多。aspect-ratio
屬性的支持,它正開始得到瀏覽器的支持。<iframe class="w-full **aspect-video** ..." src="https://www.youtube.com/..."></iframe>
在長寬比文檔中了解更多。<p> I’m Derek, an astro-engineer based in Tatooine. I like to build X-Wings at <a href="#" class="underline **decoration-sky-500 decoration-2**" >My Company, Inc</a >. Outside of work, I like to <a href="#" class="underline **decoration-pink-500 decoration-dotted decoration-2**" >watch pod-racing</a > and have <a href="#" class="underline **decoration-indigo-500 decoration-wavy decoration-2**" >light-saber</a > fights.</p>
在文本裝飾顏色、文本裝飾樣式、文本裝飾厚度和文本下劃線偏移 文檔中了解更多。rtl
和ltr
修飾符增加了對多方向布局的實(shí)驗性支持。<div class="group flex items-center"> <img class="shrink-0 h-12 w-12 rounded-full" src="..." alt="" /> > <div class="ltr:ml-3 rtl:mr-3"> <p class="text-sm font-medium text-slate-700 group-hover:text-slate-900" dark-class="text-sm font-medium text-slate-300 group-hover:text-white" > ... </p> <p class="text-sm font-medium text-slate-500 group-hover:text-slate-700" dark-class="text-sm font-medium text-slate-500 group-hover:text-slate-300" > ... </p> </div></div>
在RTL 支持文檔中了解更多。portrait
和landscape
修飾符,當(dāng)視口處于特定方向時,有條件地添加樣式。<div> <div class="portrait:hidden"> <!-- ... --> </div> <div class="landscape:hidden"> <p> This experience is designed to be viewed in landscape. Please rotate your device to view the site. </p> </div></div>
此功能的文檔的內(nèi)容比本帖的這部分內(nèi)容還要少。hover
、lg
等修飾符結(jié)合起來。<div class="[mask-type:luminance] hover:[mask-type:alpha]"> <!-- ... --></div>
這就是內(nèi)聯(lián)樣式想成為的樣子。在任意屬性 文檔中了解更多。<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Example</title>+ <script src="https://cdn.tailwindcss.com/"></script> </head> <body> <!-- --> </body> </html>
將該腳本標(biāo)簽添加到任何 HTML 文檔中,您就可以在瀏覽器中使用 Tailwind 的每一項功能。它僅用于開發(fā)目的,但它確實(shí)是一種有趣的方式,可以建立簡單的演示,或在一個新的想法上進(jìn)行探索。關(guān)鍵詞:翻譯
客戶&案例
營銷資訊
關(guān)于我們
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。