Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Använda Avståndsverktyg för Marginal och Utfyllnad | Layoutgrunder
Tailwind CSS för webbutveckling

bookAnvända Avståndsverktyg för Marginal och Utfyllnad

Du gör ett fantastiskt jobb!

Korrekt avstånd är avgörande för att skapa visuellt tilltalande och välstrukturerade layouter. Tidigare använde vi verktygsklasser för marginal och utfyllnad, men låt oss nu titta närmare på dem.

Marginal

Marginalverktyg i Tailwind CSS gör det möjligt att kontrollera avståndet runt element. De används med prefixet m- följt av ett storleksvärde. Du kan applicera marginaler på alla sidor, eller specifika sidor (topp, höger, botten, vänster) med respektive prefix (mt-, mr-, mb-, ml-).

Exempel

Margin ClassDescription
m-4Applies a margin of 1rem (16px) to all sides.
mt-2Applies a margin of 0.5rem (8px) to the top side.
mr-6Applies a margin of 1.5rem (24px) to the right side.
mb-1Applies a margin of 0.25rem (4px) to the bottom side.
ml-3Applies a margin of 0.75rem (12px) to the left side.
index.html

index.html

copy

Utfyllnad (Padding)

Utfyllnadsklasser i Tailwind CSS fungerar på liknande sätt som marginalklasser, och logiken är densamma.

De används med prefixet p- följt av ett storleksvärde. Utfyllnad kan appliceras på alla sidor, eller specifika sidor (topp, höger, botten, vänster) med respektive prefix (pt-, pr-, pb-, pl-).

Exempel

Padding ClassDescription
p-4Applies a padding of 1rem (16px) to all sides.
pt-2Applies a padding of 0.5rem (8px) to the top side.
pr-6Applies a padding of 1.5rem (24px) to the right side.
pb-1Applies a padding of 0.25rem (4px) to the bottom side.
pl-3Applies a padding of 0.75rem (12px) to the left side.
index.html

index.html

copy

Horisontell och Vertikal Avstånd

Det är även möjligt att applicera marginaler/utfyllnad på den horisontella (_x-) eller vertikala (_y-) axeln.

Exempel

ClassDescription
mx-4Applies a margin of 1rem (16px) to the left and right sides.
my-4Applies a margin of 1rem (16px) to the top and bottom sides.
px-4Applies a padding of 1rem (16px) to the left and right sides.
py-4Applies a padding of 1rem (16px) to the top and bottom sides.
index.html

index.html

copy

Obs

Om du är intresserad av att undersöka mer kring avstånd, följ gärna länkarna:

1. Vilken klass applicerar en marginal på 1rem (16px) på alla sidor av ett element?

2. Hur applicerar du en padding på 0,5rem (8px) på ovansidan av ett element?

3. Vilka är Tailwind CSS-klasserna för att applicera en marginal på 2rem (32px) på ett elements ovansida och undersida?

question mark

Vilken klass applicerar en marginal på 1rem (16px) på alla sidor av ett element?

Select the correct answer

question mark

Hur applicerar du en padding på 0,5rem (8px) på ovansidan av ett element?

Select the correct answer

question mark

Vilka är Tailwind CSS-klasserna för att applicera en marginal på 2rem (32px) på ett elements ovansida och undersida?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 1

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Awesome!

Completion rate improved to 3.57

bookAnvända Avståndsverktyg för Marginal och Utfyllnad

Svep för att visa menyn

Du gör ett fantastiskt jobb!

Korrekt avstånd är avgörande för att skapa visuellt tilltalande och välstrukturerade layouter. Tidigare använde vi verktygsklasser för marginal och utfyllnad, men låt oss nu titta närmare på dem.

Marginal

Marginalverktyg i Tailwind CSS gör det möjligt att kontrollera avståndet runt element. De används med prefixet m- följt av ett storleksvärde. Du kan applicera marginaler på alla sidor, eller specifika sidor (topp, höger, botten, vänster) med respektive prefix (mt-, mr-, mb-, ml-).

Exempel

Margin ClassDescription
m-4Applies a margin of 1rem (16px) to all sides.
mt-2Applies a margin of 0.5rem (8px) to the top side.
mr-6Applies a margin of 1.5rem (24px) to the right side.
mb-1Applies a margin of 0.25rem (4px) to the bottom side.
ml-3Applies a margin of 0.75rem (12px) to the left side.
index.html

index.html

copy

Utfyllnad (Padding)

Utfyllnadsklasser i Tailwind CSS fungerar på liknande sätt som marginalklasser, och logiken är densamma.

De används med prefixet p- följt av ett storleksvärde. Utfyllnad kan appliceras på alla sidor, eller specifika sidor (topp, höger, botten, vänster) med respektive prefix (pt-, pr-, pb-, pl-).

Exempel

Padding ClassDescription
p-4Applies a padding of 1rem (16px) to all sides.
pt-2Applies a padding of 0.5rem (8px) to the top side.
pr-6Applies a padding of 1.5rem (24px) to the right side.
pb-1Applies a padding of 0.25rem (4px) to the bottom side.
pl-3Applies a padding of 0.75rem (12px) to the left side.
index.html

index.html

copy

Horisontell och Vertikal Avstånd

Det är även möjligt att applicera marginaler/utfyllnad på den horisontella (_x-) eller vertikala (_y-) axeln.

Exempel

ClassDescription
mx-4Applies a margin of 1rem (16px) to the left and right sides.
my-4Applies a margin of 1rem (16px) to the top and bottom sides.
px-4Applies a padding of 1rem (16px) to the left and right sides.
py-4Applies a padding of 1rem (16px) to the top and bottom sides.
index.html

index.html

copy

Obs

Om du är intresserad av att undersöka mer kring avstånd, följ gärna länkarna:

1. Vilken klass applicerar en marginal på 1rem (16px) på alla sidor av ett element?

2. Hur applicerar du en padding på 0,5rem (8px) på ovansidan av ett element?

3. Vilka är Tailwind CSS-klasserna för att applicera en marginal på 2rem (32px) på ett elements ovansida och undersida?

question mark

Vilken klass applicerar en marginal på 1rem (16px) på alla sidor av ett element?

Select the correct answer

question mark

Hur applicerar du en padding på 0,5rem (8px) på ovansidan av ett element?

Select the correct answer

question mark

Vilka är Tailwind CSS-klasserna för att applicera en marginal på 2rem (32px) på ett elements ovansida och undersida?

Select the correct answer

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 4. Kapitel 1
some-alt