Css padding left right auto

Padding

Control the padding on one side of an element using the p— utilities.

For example, pt-6 would add 1.5rem of padding to the top of an element, pr-4 would add 1rem of padding to the right of an element, pb-8 would add 2rem of padding to the bottom of an element, and pl-2 would add 0.5rem of padding to the left of an element.

div class="pt-6 . ">pt-6div> div class="pr-4 . ">pr-4div> div class="pb-8 . ">pb-8div> div class="pl-2 . ">pl-2div>

Control the horizontal padding of an element using the px- utilities.

Control the vertical padding of an element using the py- utilities.

Control the padding on all sides of an element using the p- utilities.

Use the ps-* and pe-* utilities to set the padding-inline-start and padding-inline-end logical properties, which map to either the left or right side based on the text direction.

div dir="ltr"> div class="ps-8 . ">ps-8div> div class="pe-8 . ">pe-8div> div> div dir="rtl"> div class="ps-8 . ">ps-8div> div class="pe-8 . ">pe-8div> div>

For more control, you can also use the LTR and RTL modifiers to conditionally apply specific styles depending on the current text direction.

Tailwind lets you conditionally apply utility classes in different states using variant modifiers. For example, use hover : py-8 to only apply the py-8 utility on hover .

div class="py-4 hover:py-8"> div> 

For a complete list of all available state modifiers, check out the Hover, Focus, & Other States documentation.

You can also use variant modifiers to target media queries like responsive breakpoints, dark mode, prefers-reduced-motion, and more. For example, use md: py-8 to apply the py-8 utility at only medium screen sizes and above.

To learn more, check out the documentation on Responsive Design, Dark Mode and other media query modifiers.

By default, Tailwind’s padding scale uses the default spacing scale. You can customize your spacing scale by editing theme.spacing or theme.extend.spacing in your tailwind.config.js file.

module.exports =   theme:   extend:   spacing:   '5px': '5px',  >  >  >  > 

Alternatively, you can customize just the padding scale by editing theme.padding or theme.extend.padding in your tailwind.config.js file.

module.exports =   theme:   extend:   padding:   '5px': '5px',  >  >  >  > 

Learn more about customizing the default theme in the theme customization documentation.

If you need to use a one-off padding value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value.

Learn more about arbitrary value support in the arbitrary values documentation.

Copyright © 2023 Tailwind Labs Inc.

Источник

CSS Padding

Padding is used to create space around an element’s content, inside of any defined borders.

CSS Padding

The CSS padding properties are used to generate space around an element’s content, inside of any defined borders.

With CSS, you have full control over the padding. There are properties for setting the padding for each side of an element (top, right, bottom, and left).

Padding — Individual Sides

CSS has properties for specifying the padding for each side of an element:

All the padding properties can have the following values:

  • length — specifies a padding in px, pt, cm, etc.
  • % — specifies a padding in % of the width of the containing element
  • inherit — specifies that the padding should be inherited from the parent element

Note: Negative values are not allowed.

Example

Set different padding for all four sides of a element:

Padding — Shorthand Property

To shorten the code, it is possible to specify all the padding properties in one property.

The padding property is a shorthand property for the following individual padding properties:

If the padding property has four values:

Оцените статью