Brian
Brian

DivMagic a Ɔhyehyɛɛ no

Ɔberɛfɛw da 8, afe 2023

Tailwind CSS - Yɛ nnɛyi wɛbsaet ahorow ntɛmntɛm a wunnyaw wo HTML

Image 0

Sɛ wopɛ sɛ wokyekye nnɛyi, ɛyɛ adwuma, na ɛyɛ fɛ wɔ aniwa so wɛbsaet ahorow a, Tailwind CSS yɛ wo kɔ-kɔ nhyehyɛe. Ɛsakra atetesɛm CSS akyerɛw nhyehyɛe no, ɛma wo kwan ma wobɔ custom interfaces tẽẽ wɔ wo HTML mu. Tailwind CSS yɛ CSS frameworks a agye din sen biara no mu baako a ɛwɔ bɛboro ɔpepem 5 dapɛn biara instɔl.

Yɛ Nsusuwii a Ɛyɛ Den a Ɛnyɛ Den

Image 1

Tailwind CSS no, sɛ wobɛbɔ nhyehyɛɛ a ɛyɛ den abɛyɛ mframa. Mfasoɔ adesua ne responsive design utilities a wɔaka abom no ma wo kwan ma wo yɛ nhyehyeɛ a ɛyɛ nwonwa a ɛnyɛ den, a worensɛe wo wɛbsaet no adwumayɛ ne ne siesie.

Si biribiara

Image 2

Tailwind CSS ahoɔfɛ gyina sɛnea ɛyɛ adwuma wɔ mmeae pii no so. Wubetumi ayɛ biribiara afi blog krataafa a ɛnyɛ den so akɔ e-commerce platform a ɛkɔ anim so, ne nyinaa bere a wode utility classes a ɛyɛ mmerɛw koro no ara redi dwuma no.

W’adwene nkutoo na ɛto wo ano hye. Nsonsonoe titiriw a ɛwɔ Vanilla CSS a wode bedi dwuma no mu ne ahoɔhare a wubetumi de ayɛ nhyehyɛe ahorow a wɔahyɛ da ayɛ.

Atetesɛm kwan a wɔfa so de custom css classes a html components te sɛ div, div class, p class di dwuma no yɛ option bere nyinaa nanso ahoɔhare nkɔso a ɛba ne Tailwind CSS no ma w’asetra yɛ mmerɛw.

Nneyɛe pa a wɔyɛ no nyɛ adwuma ankasa

Image 3

Sɛnea wɔtaa yɛ no, wɔkyerɛw CSS denam wiase nyinaa akwan horow a wɔde besi hɔ na wɔsiesie no yiye wɔ ade biara mu. Bere a eyi yɛ ɔkwan a agye din no, ebetumi ama wɔayɛ mmara a ɛyɛ kɛse na ɛyɛ den sɛ wɔbɛhwɛ so.

Tailwind CSS twa saa adwene yi mpoa, na ɛka sɛ utility-first CSS de ano aduru a ɛho tew, a wotumi hwɛ so yiye ma.

Component nhomakorabea a agye din sen biara ma Tailwind CSS

Image 4

daisyUI yɛ component library a agye din sen biara ma Tailwind CSS, ɛhoahoa ne ho bɛboro 50 a wɔadi kan ayɛ components, 500+ utility classes, ne ɛkame ayɛ sɛ enni awiei a ebetumi aba. Ɛgye wo fi ntwahonan no a wobɛsan ayɛ bere biara a wobɛbɔ adwuma foforo bi no mu.

Mma Nsan Nyɛ Twɛre no Bere Biara

Image 5

Sɛ anka wobɛsɛe wo bere wɔ ɔkwan a ɛyɛ ɔbrɛ a ɛne sɛ wobɛkyerɛw adesuakuw din du du pii ama adwuma foforo biara no, Tailwind CSS ma wutumi de adesua ahorow a mfaso wɔ so a wɔakyerɛkyerɛ mu yiye, a ntease wom di dwuma.

Saa adesua ahorow yi yɛ nea wotumi de di dwuma bio na ɛne CSS cascade no yɛ adwuma pɛpɛɛpɛ, na ɛma wunya fapem a ɛyɛ den ma wo nnwuma nyinaa.

Tailwind CSS - A Utility a Edi Kan CSS Nhyehyɛe

Image 6

Wɔ ne titiriw mu no, Tailwind CSS yɛ CSS nhyehyɛe a edi kan a ɛfa mfaso ho. Wei kyerɛ sɛ ɛma utility classes a ɛba fam, a wotumi hyehyɛ a wobɛtumi de ayɛ design biara, tẽẽ wɔ wo HTML mu. CSS fael a enni awiei nni hɔ bio, code a ɛyɛ mmerɛw na ɛyɛ mmerɛw nkutoo.

Fa Semantic Class Names Di Dwuma

Image 7

Semantic class din ahorow ma wo code no akenkan tu mpɔn, na ɛma ɛyɛ mmerɛw sɛ wobɛte nea class pɔtee bi yɛ ase denam ne din a wobɛhwɛ ara kwa so. Eyi yɛ nneɛma pii a Tailwind CSS agye atom de ama developer osuahu no atu mpɔn no mu biako.

CSS a ɛho tew. Nhyehyɛe Agnostic. Adwuma Wɔ Baabiara

Image 8

Tailwind CSS nkyekyere wo wɔ framework pɔtee biara mu. Ɛyɛ CSS kronkron kɛkɛ, enti wobɛtumi de adi dwuma ne framework biara, anaa mpo a framework biara nni mu koraa. Ɛyɛ adwuma wɔ baabiara a CSS yɛ adwuma.

Mfaso a ɛwɔ Tailwind CSS so

Image 9

Mfasoɔ a ɛwɔ Tailwind CSS a wode bedi dwuma no bi ne adwumayɛ a ɛkɔ soro, CSS fael kɛseɛ a ɛso atew, ne developer osuahu a ɛkɔ anim ɛnam utility-first kwan no nti. Bio nso, Just-In-Time (JIT) mode no ma wonya adansi bere a ɛyɛ ntɛmntɛm te sɛ anyinam, na ɛma wo nkɔso nhyehyɛe no yɛ ntɛmntɛm bio.

Tailwind CSS Boɔ a Wɔbɔ

Image 10

Tailwind CSS yɛ open-source project, a ɛkyerɛ sɛ ɛyɛ free koraa sɛ wode bedi dwuma. Ɛka no ba bere a wopɛ sɛ wonya premium features te sɛ UI components ne templates, a wɔde ma denam Tailwind UI so.

Ɛyɛ adwene ne nsakrae bere koro no ara mu

Image 11

Tailwind CSS ma adwene a emu yɛ den wɔ sɛnea wobɛhyehyɛ wo CSS no ho, nanso ɛyɛ nea ɛyɛ mmerɛw a ɛbɛma woatumi ayɛ nsakrae. Saa kari pɛ yi ma wotumi de w’adwene si nea ɛho hia kɛse so — UI ahorow a ɛyɛ fɛ a wobɛkyekye.

Nnɛyi nneɛma a ɛwɔ hɔ

Image 12

Tailwind CSS gye nnɛyi nneɛma te sɛ Flexbox, Grid, ne amanne kwan so agyapade tom, na ɛma ɛyɛ paw a eye kyɛn so ma nnɛyi wɛb aplikeshɔn ahorow a wɔbɛyɛ.

Nneɛma a ɛsɛ sɛ wodi kan de di dwuma ansa na wode Tailwind CSS adi dwuma

Image 13

Ansa na wobɛhyɛ aseɛ de Tailwind CSS adi dwuma no, ɛhia sɛ wonya HTML ne CSS ho nteaseɛ titire.

Bere a Ɛsɛ sɛ wode Tailwind CSS Di Dwuma

Image 14

Tailwind CSS fata ma wɛb nnwuma ahodoɔ nyinaa, akɛseɛ anaa nketewa. Sɛ woabrɛ sɛ wo ne CSS bɛpere na worehwehwɛ ano aduru a ɛyɛ adwuma yiye, a ɛyɛ developer-adamfofa a, ɛnde Tailwind CSS yɛ ma wo.

Ɛnyɛ sɛ ɛkɔ component frameworks mu?

Image 15

Sɛ wonyɛ fan a component frameworks te sɛ React anaa Vue a, ɛnhaw wo. Tailwind CSS yɛ framework-agnostic na wobetumi de HTML ne JavaScript kronkron adi dwuma.

Nsɛsoɔ ne Nsonsonoeɛ a ɛda Tailwind CSS ne CSS Frameworks Afoforo ntam

Image 16

Bere a nhyehyeɛ foforɔ te sɛ Bootstrap ne Foundation de nneɛma a wɔadi kan ayɛ ma no, Tailwind CSS ma wo nnwinnadeɛ a wode bɛkyekyere nhyehyɛɛ a wɔahyɛ da ayɛ koraa a worennyae wo HTML. Nanso, ɛdenam component libraries te sɛ daisyUI a wɔaka abom so no, afei wubetumi anya wiase abien no nyinaa mu nea eye sen biara no mu anigye.

Esum Mode

Image 17

Tailwind CSS ne daisyUI mu nneɛma a aba foforo no mu biako ne esum mode, a ɛma wutumi yɛ wɛbsaet ahorow a ɛwɔ asɛmti a ɛyɛ sum a wommɔ mmɔden biara.

Flexbox Nhwɛso

Image 18

Tailwind CSS ne nnɛyi CSS nneɛma te sɛ Flexbox di nkitaho yiye. Sɛ nhwɛso no, wubetumi de adesua ahorow te sɛ flex, justify- center, items-center, ne nea ɛkeka ho ayɛ nhyehyɛe a ɛyɛ mmuae.

Sɛ wode Just-in-Time ka bom a, wobɛtumi asɔ utility class value ahodoɔ ahwɛ ntɛm. Sɛ utility class biako anyɛ adwuma a, sesa no kɛkɛ na ama woayɛ wo element no sɛnea wopɛ.

Flexbox Nsiesiei Nhwɛso

Image 19

Sɛ wode Tailwind CSS di dwuma a, ɛnyɛ den sɛ wobɛbɔ nhyehyɛe a ɛyɛ den te sɛ akwantuo kwan a ɛyɛ mmuaeɛ. Nhwɛso bi ni:

<nav class="flex items-center justify-between flex-wrap bg-teal-500 p-6">
  <div class="flex items-center flex-shrink-0 text-white mr-6">
    <span class="font-semibold text-xl tracking-tight">Tailwind CSS</span>
  </div>
  <div class="block lg:hidden">
    <button class="flex items-center px-3 py-2 border rounded text-teal-200 border-teal-400 hover:text-white hover:border-white">
      <svg class="fill-current h-3 w-3" viewBox="0 0 20 20"><path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v15z"></path></svg>
    </button>
  </div>
  <div class="w-full block flex-grow lg:flex lg:items-center lg:w-auto">
    <div class="text-sm lg:flex-grow">
      <a href="#responsive-header" class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4">Home</a>
      <a href="#responsive-header" class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white mr-4">About</a>
      <a href="#responsive-header" class="block mt-4 lg:inline-block lg:mt-0 text-teal-200 hover:text-white">Contact</a>
    </div>
  </div>
</nav>

Nneɛma a wɔde yɛ nneɛma a wɔasiesie

Image 20

Sɛ wo sii gyinae sɛ wode tailwind css code bedi dwuma wɔ wo project no mu a, wobɛtumi anya premade components pii wɔ intanɛt so. Wubetumi ayɛ eyinom mu biara ho mfonini na woayɛ no sɛnea wopɛ ama w’ankasa wɛbsaet.

Sɛnea wobɛdannan CSS akɔ Tailwind CSS mu

Image 21

Sɛ wobɛtumi adan CSS akɔ Tailwind CSS adesua mu a, ɛyɛ biribi a developers dodoɔ no ara hia. Wɛbsaet pii wɔ intanɛt so a wɔasi ansa na Tailwind CSS reba. Saa wɛb nkratafa yi de css a ɛwɔ stylesheet di dwuma na wɛb nkɔsoɔ adwumayɛfoɔ pɛ sɛ wɔtu saa nkratafa yi kɔ Tailwind CSS.

DivMagic yɛ wɛb nkɔsoɔ adwinnadeɛ a wɔasi ama wɛb developer ne software developers. Ɛma kwan ma wɔtumi kɔpi style biara firi vanilla css so kɔ Tailwind CSS so. Sɛ wobɔ prɛko pɛ a, wobɛtumi adan adeɛ biara a ɛwɔ intanɛt so akɔ Tailwind CSS mu na wode Tailwind adi dwuma wɔ wo dwumadie no mu na woayɛ ɔkwan biara a wopɛ.

Dive Deep kɔ Tailwind CSS Nyansapɛ mu

Image 22

Nyansapɛ a ɛwɔ Tailwind CSS akyi ne sɛ wɔde wɔn adwene besi mfasoɔ so. Wei kyerɛ sɛ sɛ anka wobɛdi kan akyerɛkyerɛ component classes mu no, Tailwind CSS de low-level utility classes a ɛma wotumi yɛ designs soronko a wonnyae wo HTML no ma.

Dɛn Nti na Wotwe Wo ho Fi Amanneɛ kwan so CSS ho?

Image 23

Amanneɛ kwan so CSS betumi ama wɔde overrides, fael a ayɛ bloated, ne 'div soup' adi dwuma dodo. Sɛ wodane kɔ utility-first CSS framework te sɛ Tailwind CSS so a, wobɛtumi abrɛ saa nsɛm yi ase, na ɛde codebase a ɛho tew, ɛyɛ mmerɛw aba.

Nya Tumi a ɛwɔ Utility Classes mu no mu osuahu

Image 24

Utility classes boa wo ma wokwati sɛ wobɛsan ayɛ styles koro no ara wɔ wo stylesheets nyinaa mu. Ɛyɛ nnyinasosɛm a ɛne "Don’t Repeat Yourself" (DRY). Saa adesua ahorow yi gye wo bere ne mmɔdenbɔ kɛse na ɛde kɔ codebase a wotumi hwɛ so yiye so.

Tailwind CSS Akwankyerɛ a Wɔhwehwɛ mu

Image 25

Tailwind CSS de akwankyerɛ kakraa bi a wobɛtumi de adi dwuma wɔ wo stylesheets mu no ba. Eyinom bi ne @apply , @variants , ne @screen. Sɛ wote saa akwankyerɛ yi ase na wode di dwuma a, ɛbɛtumi ama wo Tailwind CSS suahunu no ayɛ yie kɛseɛ. Wobetumi de eyinom ahyɛ Tailwind Config CSS fael no mu. Wubetumi de saa kwan yi akyerɛw css adesua ahorow.

Trɛw Tailwind CSS mu denam Plugins so

Image 26

Wobetumi de plugins atrɛw Tailwind CSS mu, de dwumadie foforɔ aka ho anaasɛ wɔbɛsesa deɛ ɛwɔ hɔ dada no. Sua sɛnea wode plugins bedi dwuma de ama wo wɛb nnwuma no ayɛ adwuma yiye na ayɛ fɛ kɛse.

Fa Tailwind CSS ka Wo Adwumayɛ ho

Image 27

Tailwind CSS a wode bɛka wo nkɔsoɔ adwumayɛ ho no yɛ tẽẽ, sɛ wode adansi nnwinnadeɛ te sɛ Webpack anaa Parcel redi dwuma, anaasɛ wode frameworks te sɛ Next.js anaa Gatsby reyɛ adwuma.

Fa Tailwind CSS ma Nkɔanim Nkɔanim

Image 28

Tailwind CSS hyɛ nhyehyɛɛ a wotumi nya ho nkuran denam ARIA su ahorow bi a wɔde bɛka ne adesuakuw ahorow ho no so. Yɛ interfaces a ɛyɛ mmerɛw sɛ wobɛkɔ so na ma osuahu a ɔde di dwuma no ayɛ yiye ama obiara.

Fa Flexbox ne Grid Tumi di dwuma denam Tailwind CSS so

Fa nnɛyi CSS nhyehyeɛ module te sɛ Flexbox ne Grid ne Tailwind CSS di dwuma. Sua sɛnea wobetumi de utility classes adi dwuma de adi nhyehyɛe so wɔ ɔkwan a ɛyɛ mmerɛw na ɛyɛ mmuae so.

Sɛnea Wobɛsiesie Wo Tailwind CSS Nnwuma

Tailwind CSS de debugging nnwinnade ne akwan pii a ɛma ɛyɛ mmerɛw sɛ wobehu na wɔadi styling nsɛm ho dwuma. Te saa nnwinnade yi ase na ma wo debugging nimdeɛ nkɔ anim.

Fa Tailwind CSS yɛ Wɛb a Ɛyɛ Kɔla

Tailwind CSS de kɔla ahorow a ɛtrɛw a wotumi sesa no ba. Sua sɛnea wode kɔla ahorow yi bedi dwuma na woayɛ no sɛnea wopɛ de ayɛ mfonini ahorow a ɛyɛ hyew na ɛyɛ fɛ wɔ aniwa so.

Nkɔso Ntɛmntɛm ne Tailwind CSS' JIT Mode

Kɔ Tailwind CSS no Just-In-Time mode no mu kɔ akyiri. Te sɛnea ɛyɛ adwuma ne sɛnea ebetumi ama wo nkɔso akɔ ntɛmntɛm kɛse na woakyekye mmere no ase.

Efi Zero so kɔ Hero so: Owura Tailwind CSS

Fi ase tu kwan a ɛbɛma woatumi ayɛ Tailwind CSS yiye. Efi baabi a wobɛhyehyɛ so kosi nsɛmti a ɛkɔ akyiri a wobɛhwehwɛ mu so no, akwankyerɛ a ɛkɔ akyiri yi ama woaka ho asɛm.

Yɛ Tailwind CSS no sɛnea W’ahiade te

Tailwind CSS ahoɔden kɛseɛ baako ne sɛ ɛyɛ nsakraeɛ. Sua sɛnea wobɛsesa Tailwind ma ɛne wo project no ahiadeɛ pɔtee ahyia.

Nsa a wobɛnya wɔ Tailwind CSS so

Fa wo ho hyɛ nsaano adesua mu denam nhwɛso ahorow a mfaso wɔ so a ɛtoatoa so so. Hwehwɛ sɛnea wobɛkyekyere wɛb afã ahorow denam Tailwind CSS ne DaisyUI so.

Woretu afiri CSS Frameworks Afoforo so akɔ Tailwind CSS so

Woresusuw ho sɛ wobɛdan akɔ Tailwind CSS so? Te nsonsonoe titiriw a ɛda Tailwind ne nhyehyɛe afoforo ntam ase, na sua akwan a etu mpɔn a wobɛfa so atu wo nnwuma no.

Wubetumi de DivMagic anaa nnwinnade a ɛte saa adi dwuma de ama wo tu ahoɔhare akɔ soro kɛse.

Wɛb nkɔso nnwinnade te sɛ DivMagic ma wo kwan ma wode kɔpi element biara design biara ne style biara fi wɛbsaet biara so denam klike biako so.

Nhwɛso a Ɛyɛ Mmerewa: Kaad a Ɛma Mmuae a Wobɛkyekye

Nhwɛsoɔ a ɛkyerɛ sɛdeɛ wobɛtumi ayɛ responsive card component denam Tailwind CSS so ni. Saa ade yi bɛkura mfonini, asɛmti, ne nkyerɛkyerɛmu.

<div class="max-w-md mx-auto bg-white rounded-xl shadow-md overflow-hidden md:max-w-2xl">
  <div class="md:flex">
    <div class="md:flex-shrink-0">
      <img class="h-48 w-full object-cover md:w-48" src="/img/store.jpg" alt="Store">
    </div>
    <div class="p-8">
      <div class="uppercase tracking-wide text-sm text-indigo-500 font-semibold">Your Product</div>
      <p class="mt-2 text-gray-500">This is a brief description of your product. The card uses utility classes for padding, text color, and the uppercase font styling.</p>
    </div>
  </div>
</div>

Sɛ wode Tailwind CSS reyɛ Form a

Sɛ wode Tailwind CSS bɛyɛ fom a, ɛyɛ tẽẽ na ɛyɛ mmerɛw. Nkitahodi kratasin a ɛnyɛ den ni:

<div class="w-full max-w-xs">
  <form class="bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4">
    <div class="mb-4">
      <label class="block text-gray-700 text-sm font-bold mb-2" for="username">
        Username
      </label>
      <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" id="username" type="text" placeholder="Username">
    </div>
    <div class="mb-6">
      <label class="block text-gray-700 text-sm font-bold mb-2" for="password">
        Password
      </label>
      <input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline" id="password" type="password" placeholder="******************">
    </div>
    <div class="flex items-center justify-between">
      <button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline" type="button">
        Sign In
      </button>
    </div>
  </form>
</div>

Tailwind CSS a wɔreyɛ no sɛnea wopɛ

Tailwind CSS ma wo kwan ma wo sesa ne default nhyehyeɛ, a ɛyɛ utility classes no ma ɛne w'ahiadeɛ hyia. Ase hɔ no, nhwɛso bi wɔ hɔ a ɛkyerɛ sɛnea wobɛsesa kɔla ahorow no.

Saa nhwɛsoɔ yi kyerɛ Tailwind CSS a ɛyɛ mmerɛw na ɛyɛ mmerɛw, ɛkyerɛ sɛnea wobetumi aboa wo ma woayɛ nnɛyi, wɛb afã horow a ɛyɛ adwuma yiye na ɛyɛ adwuma yiye.

module.exports = {
  theme: {
    extend: {
      colors: {
        'custom-blue': '#243c5a',
        'custom-green': '#387c6d',
      }
    }
  }
}

So mehia CSS fael biara?

Fael biako pɛ a wuhia wɔ Tailwind CSS ho ne tailwind.config.js fael no.

Saa fael no bɛkura wo nhyehyeɛ nhyehyeɛ no. Worenkyerɛw css anaasɛ worennya css fael foforo biara. Saa nhyehyeɛ fael yi nko ara na wobɛhia.

Dɛn ne nneyɛe pa a ɛwɔ Tailwind CSS mu?

Sɛ wopɛ nkyerɛkyerɛmu a ɛkɔ akyiri wɔ Tailwind CSS nneyɛe pa ho a, yɛsrɛ wo hwɛ yɛn asɛm foforo Tailwind CSS Nneyɛe Pa.

Tailwind CSS: Daakye a Ɛfa Wɛb Nsusuwii Ho

Susuw sɛnea Tailwind CSS reyɛ daakye wɔ wɛb nhyehyɛe ho. Sua ne nkɛntɛnso ne tumi a ebetumi ama nkɔso wɔ wɛb nkɔso adwuma mu ho ade.

Wopɛ sɛ wokɔ so nya nsɛm foforo?
Kɔka DivMagic email list no ho!

Yɛ obi a odi kan a obehu nsɛm ho amanneɛbɔ, nneɛma foforo ne nea ɛkeka ho!

Yi wo ho fi wo ho bere biara. Spam biara nni hɔ.

© 2024 DivMagic, Inc. Hokwan nyinaa wɔ hɔ.