Tag:Horizontal vertical center
-
Time:2020-11-19
Translate (- 50%, – 50%) attribute:Up and left, move 50% of its length and width to center it. Different from using margin to realize centering, margin must know its width and height, while translate can center without knowing its width and height. The percentage in tranlate function is relative to its width and height(when top […]
-
Time:2020-11-13
Div basic layout <div class=”main”> <div class=”center”></div> </div> CSS Style 1. Coordinate positioning and margin: Auto Relative positioning is added to the parent element, and absolute positioning is added to the child element .main{ width: 300px; height: 300px; background-color: red; position: relative; } .center{ width: 100px; height: 100px; background-color: skyblue; position: absolute; left: 0; right: […]
-
Time:2020-6-27
As a front-end monkey, we will encounter the effect of “using CSS to center” more or less, no matter when we are interviewing or working. Today, I will write an article about several methods of CSS vertical and horizontal center. Chestnut 1: start with the simplest horizontal center margin: 0 auto; Block level elements use […]