Social Icons

Pages

Tuesday, November 29, 2016

CSS Positioning 7/25

Margin
Let's start with our margins. Adjusting our margins not only moves our element relative to other elements on the page, but also relative to the "walls" of the HTML document.
For instance, if we take an HTML element with a specific width (such as our <div> in the editor) and set its margin to auto, this tells the document to automatically put equal left and right margins on our element, centering it on the page.

Instructions
Try it out! Set our div's margin property toauto to center our div on the page.

* {
 border: 1px dashed black;
}

div {
 height: 50px;
 width: 100px;
 border: 2px solid black;
 border-radius: 5px;
 background-color: #308014;
 margin:auto;
}

No comments:

Post a Comment