divmagic Make design
SimpleNowLiveFunMatterSimple
Brian
Brian

DivMagic Muvambi

Chivabvu 12, 2023

Tailwind Best Practices - The Ultimate Guide for Tailwind CSS

Image 0

Kana zvasvika pakuita zvekushandisa-kutanga CSS, Tailwind CSS yave yekuenda-kune mhinduro kune vakawanda vanogadzira.

Iko kuchinjika, kuita, uye nyore kushandisa kwainopa kwakaratidza kukosha mukuvandudza kwewebhu kwazvino.

Nekudaro, senge chero chishandiso, kuti uwane zvakanyanya kubva mazviri, zvakakosha kuti unzwisise nekushandisa Tailwind CSS maitiro akanakisa.

Ngatinyure mune dzimwe nzira idzi.

1. Utility-Chekutanga Basics

Iyo yekushandisa-yekutanga huzivi ndiyo musimboti weTailwind CSS, iine chinangwa chekugonesa vagadziri vane yakaderera-level utility makirasi panzvimbo pezvakafanogadzirwa zvinhu. Maitiro aya anogona kutanga kuita seanoomesera nekuda kweshoko reHTML rako; zvisinei, kana yangonzwisiswa, inogonesa kukurumidza prototyping uye kugadzirwa-chikamu chekugadzirisa.

Mune utility-yekutanga architecture, kirasi yega yega inoenderana neyakasiyana maitiro hunhu. Semuyenzaniso, kirasi-yepakati kirasi inogadzirisa zvinyorwa zvako nepakati, nepo bg-blue-500 ichapa chinhu chako mumvuri chaiwo webhuruu kumashure.

Iyi nzira inosimudzira kudzoreredzwa kwechikamu uye inoderedza huwandu hweCSS yaunonyora, kubvisa zvinowanzoitika senge hondo chaiyo uye kufa kwekodhi kubviswa.

2. Inopindura Dhizaini

Tailwind CSS zvakare inokunda mune inoteerera dhizaini. Iyo inoshandisa mobile-yekutanga breakpoint system, zvichireva kuti masitaera akaiswa kune madiki skrini anogona kuyerera nyore kune akakura. Izvi zvinogona kuitwa uchishandisa maprefixes akareruka senge sm:, md:, lg:, uye xl: pamberi pemakirasi ako ekushandisa.

Semuenzaniso, md:text-center inongoshandisa iyo text-center kirasi pane epakati uye makuru skrini. Izvi zvinokutendera kuti ugadzire intuitively kune akasiyana skrini saizi, ichiita inopindura dhizaini mhepo ine Tailwind.

3. Kushandisazve Zvitaera

Nepo zvekushandisa-kutanga zvichikurudzira kushandisa zvitaera zvakananga kuHTML yako, kudzokorora musanganiswa wakaoma wezvishandiso zvinogona kunetsa. Pano, Tailwind's @apply dhairekitori inova muponesi, ichikubvumidza kuti ubvise zvitaera zvakadzokororwa mumakirasi eCSS etsika.

Semuyenzaniso, kana uchigaro shandisa musanganiswa webg-red-500 text-white p-6, unogona kugadzira kirasi itsva senge .error uye shandisa @apply kushandisazve masitayera aya. Izvi zvinowedzera kuverenga kwekodhi uye kuchengetedza.

4. Kuwedzera Custom Styles

Kunyangwe Tailwind CSS ichiuya neyakasiyana siyana yemakirasi ekushandisa, ungangoda masitaera etsika kune chaiwo zvinodiwa. Tailwind inopa zvakakura zvekugadzirisa sarudzo kuburikidza nefaira rekugadzirisa, tailwind.config.js.

Iwe unogona kuwedzera iyo yakasarudzika kumisikidzwa, kugadzira tsika mavara, breakpoints, mafonti, nezvimwe. Izvo zvakakosha, zvisinei, kushandisa iyi ficha zvishoma kudzivirira bloating yako yekumisikidza faira.

5. Mabasa & Mazano

Tailwind CSS inopa akati wandei mabasa uye mirairo kuita kuti ruzivo rwako rwekusimudzira runyararo. Semuenzaniso, iyo theme () basa rinokutendera iwe kuti uwane yako yekumisikidza tsika zvakananga muCSS yako, kufambisa maitiro ekuchinja.

Zvakare, mirairo yaTailwind, senge @responsive, @variants, uye @apply, inokutendera kuti ugadzire inopindura, misiyano yenyika, uye kubvisa zvitaera zvakadzokororwa, zvichiteerana. Kushandisa aya mabasa uye mirairo nenzira kwayo kuchakurumidzisa maitiro ako ekusimudzira uye chengetedza yako codebase yakarongeka.

6. Kubata Hover, Focus, uye Dzimwe Nyika

Imwe nharaunda iyo Tailwind CSS inopenya iri kubata akasiyana ma element. Kuisa masitayipi pane hover, kutarisa, inoshanda, uye dzimwe nyika zviri nyore sekutanga kirasi yekushandisa ine zita renyika.

Semuyenzaniso, hover:bg-blue-500 ichaisa iyo bg-blue-500 kirasi kana chinhu chatenderedzwa pamusoro. Aya maprefixes anopa yakakwira mwero wekutonga pamusoro pemabatiro anoita zvinhu munzvimbo dzakasiyana, kuwedzera saiti yako mushandisi ruzivo.

Mukupedzisa, kugona aya Tailwind CSS maitiro akanakisa anogona kusimudzira zvakanyanya maitiro ako ekuvandudza webhu. Nzira yekushandisa-yekutanga, kana yasanganiswa nekushandisa zvakare zvitaera, magadzirirwo, uye ruoko rwakanaka

Kuvandudza yako Tailwind CSS workflow neDivMagic

Kana iwe uri kutsvaga kuvandudza yako Tailwind CSS mafambiro, tarisa DivMagic, browser yekuwedzera iyo inokutendera iwe kukopa uye kushandura Tailwind CSS makirasi zvakananga kubva kubrowser yako uye inoshanda pane chero webhusaiti.

Chrome:Isa yeChrome
Firefox:Isa Firefox

Une mhinduro kana dambudziko? Tizivise kuburikidza nepuratifomu yedu, uye isu tichabata zvimwe!

Unoda kugara uchiziva here?

Joinha iyo DivMagic email list!

© 2024 DivMagic, Inc. Kodzero dzese dzakachengetwa.