CSS Bologna 👨‍🏫

Margin

🏡 Home

Margin is effectively the same as padding, except you are able to use negative values and pull elements outside of parent elements.

Negative Margin

.child {
margin-left: -40px;
}
Parent
Child



Auto Margin

This tells the browser to render equal amounts of space between the left and the right sides of the element, which will center it.

.element {
margin: auto;
}
margin: auto;



Examples of Using Negative Margin

This is a Title

Amicissime meus Harrius et pecuniam nostram servamus ut deliciolum nostrum aperiamus. Possedi vermes. Id quod amet vocamus, "Vangiones accepi." Lorem in amet vermibus praedia vendere.

💡

Amicissime meus Harrius et pecuniam nostram servamus ut deliciolum nostrum aperiamus. Possedi vermes. Id quod amet vocamus, "Vangiones accepi." Lorem in amet vermibus praedia vendere.