+ 1

What are the properties of CSS to specify the margin for each side of an element

CSS

25th Dec 2016, 4:23 PM
Anonym
Anonym - avatar
3 Answers
+ 3
Precision: If: margin-top: 10px; margin-right: 20px; margin-bottom: 30px; margin-left: 40px; Then: margin: 10px 20px 30px 40px; /* top, right, bottom, left */ Others shorcuts are possible, with 1, 2, or 3 values ( respectively, all 4 margins, top-bottom and left-right, top left-right and bottom ) Instead numeric values with unit, you can set the value "auto" ( usefull sometimes for center an element like a <table> who can have some difficult to be ) In addition to the margin and on the same model, there's padding, wich is internal margin of an element ( imagine you set a border, permits to the content not be sticky to it )
25th Dec 2016, 4:49 PM
visph
visph - avatar
+ 2
margin: 100px; is the shortcut for margin-top: 100px; margin-right: 100px; margin-bottom: 100px; margin-left: 100px; if you specify 4 values instead of one, the margin will be set in following order: top, right, bottom, left the example above could also be written as margin: 100px 100px 100px 100px;
25th Dec 2016, 4:29 PM
qobus
- 1
che guvera
28th Dec 2016, 5:10 PM
Israr Khan
Israr Khan - avatar