Changes on centering an element using margins. (#20170)

Changes has been made on aligning an element to the center by changing the margin values.
This commit is contained in:
allenpbiju
2018-10-28 09:30:19 +05:30
committed by Christopher McCormack
parent c09dce92dd
commit c7d64100a3

View File

@ -42,6 +42,18 @@ The margin property in CSS defines the outermost portion of the box model, creat
## Collapsing margins ## Collapsing margins
Vertical margins on different elements that touch each other (thus have no content, padding, or borders separating them) will collapse, forming a single margin that is equal to the greater of the adjoining margins. This does not happen on horizontal margins (left and right), only vertical (top and bottom). Vertical margins on different elements that touch each other (thus have no content, padding, or borders separating them) will collapse, forming a single margin that is equal to the greater of the adjoining margins. This does not happen on horizontal margins (left and right), only vertical (top and bottom).
## Centering an element using margin
An element can be aligned to the center by making it a block element and changing the values of the left and right margins to auto.
```css
.c-pos {
display: block;
margin-left: auto;
margin-right: auto;
}
```
## Browser Support ## Browser Support
It is effectively supported in all browsers (since IE6+, Firefox 2+, Chrome 1+ etc) It is effectively supported in all browsers (since IE6+, Firefox 2+, Chrome 1+ etc)