margin by codecademy

2014. 8. 21. 10:52EXPERIENCE/WEB | HTML5&JS&CSS

반응형

margin

The properties margin-left, andmargin-right are available to set themargin on either side of an HTML element. If one of these properties is set to auto, then it will take as much as possible.

To move the HTML element to the far left of the screen, use margin-right: auto. This will maximize the amount of space there is on the right side margin, pushing the element to the far left.

To center an element, setmargin-right: auto and margin-left: auto. The margin to the left and right will be equal and the element will be centered.


스크린의 왼쪽으로 떨어트리고 싶을때는 ,  margin-right: auto

오른쪽의 margin 공백을 최대치로 두기때문에, 왼쪽으로 이동하게 된다. 


요소를 중앙으로 데려오고 싶을 경우, margin-right: auto and margin-left: auto

 하게되면, 그 요소들이 각각 동일하게 여백이 적용될 것이라, 중간에 올 것이다. 



반응형