Hướng dẫn dùng w3schools padding trong PHP
Padding is used to create space around an element's content, inside of any defined borders. Show This element has a padding of 70px. Try it Yourself » CSS PaddingThe CSS 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 SidesCSS has properties for specifying the padding for each side of an element:
All the padding properties can have the following values:
Note: Negative values are not allowed. ExampleSet different padding for all four sides of a element: div { Try it Yourself » Padding - Shorthand PropertyTo shorten the code, it is possible to specify all the padding properties in one property. The
So, here is how it works: If the
ExampleUse the padding shorthand property with four values: div { Try it Yourself » If the
ExampleUse the padding shorthand property with three values: div { Try it Yourself » If the
ExampleUse the padding shorthand property with two values: div { Try it Yourself » If the
ExampleUse the padding shorthand property with one value: div { Try it Yourself » Padding and Element WidthThe CSS So, if an element has a specified width, the padding added to that element will be added to the total width of the element. This is often an undesirable result. ExampleHere, the element is given a width of 300px. However, the actual width of the element will be 350px (300px + 25px of left padding + 25px of right
padding):
div { Try it Yourself » To keep the width at 300px, no matter the amount of padding, you can use the ExampleUse the box-sizing property to keep the width at 300px, no matter the amount of padding: div { Try it Yourself » More ExamplesSet the left padding element. Set the right padding element. Set the top padding element. Set the bottom padding element. Test Yourself With ExercisesExercise:Set the top padding of the element to 30 pixels.
Start the Exercise All CSS Padding Properties
|