A margin you can make massive response element centered, very practical

Before too many ways to sum up the middle level, but today see a characteristic margin, the line of code to get very practical "css World" this book, share

margin: autoAutomatically fill the remaining width and height is set after the width and height of block elements. margin: autoPrerequisite for the automatic filling element is triggered automatically populated with the corresponding characteristics in the horizontal or vertical direction, the default height is clearly the case that the block elements do not have this condition. Typical applications are implemented in the block element level Bureau of:

display: block;
width: 200px;
margin: 0 auto;

autoFeature is that if both sides auto, both the average remaining width; if one side marginis fixed, the other side is auto, the side of autothe remaining width. Examples ↓

 

It is not very convenient

Of course, in addition to the horizontal direction and the vertical direction margincan be realized vertically centered, but requires elements with automatic filling properties in the vertical direction, and this characteristic can be utilized positionto realize:

.mm>div{

position: absolute;
left: 0; right: 0; top: 0; bottom: 0;
width: 200px;
height: 200px;
margin: auto;}

 

Guess you like

Origin www.cnblogs.com/bobo1/p/12370160.html