html + css horizontal and vertical centering

1. The fixed-width horizontal centering. Left: margin: auto 2. flexible pouch disposed justify-content: center 3. parent element arranged text-align: center 4 relative positioning elements left: 0; right: 0; fixed width: left margin: auto 5. margin relative positioning element -left: 50%; transform: translateX (-50%) [margin, padding block comprises a percentage of the width of the vertical center 1.line-height] [2] vertical center line text box is provided an elastic align-items: center 3 The relative positioning of the element top: 0; bottom: 0; set high: upper and lower margin: auto 4. element located opposite, top: 50%, transform: translateY (-50%) relative to the horizontal element vertically centered position: relative; top: 50 % left: 50% teansform: translate (-50%, - 50%)

Guess you like

Origin www.cnblogs.com/dbda/p/11249950.html