background

Remember the beginning of the development work, for the setting of CSS does not take effect, upset, often a variety of search results, often harvest a lot of new knowledge, a “oh, so so!” Contented, no habit of recording. With the growth of working years, CSS problems encountered more, more solutions, the horizon has indeed widened a lot, but the details of the knowledge point is not remembered, resulting in deja vu often encountered style problems, and finally, it is good to change a solution to achieve.

Now reflecting on the previous practice is really a big loss, resulting in personal skills:

  1. Knowledge networks are not built;
  2. Skills have no depth, only superficial, stay in the problem solving stage, do not really understand the problem;
  3. Even less likely to be integrated;

Remember the teacher of the past, draw lessons from the future, start to record the problems encountered in the development process, and appropriately summarize the relevant problems along the way;


The body of the

Today, when I centered the outer div of a loading component, I didn’t want to add a heavy Flex layout because the loading component was dynamically displayed and the development function was basically completed. I just wanted to add a margin:’0 auto’ for loading. To achieve left-right center, but surprisingly, it didn’t work.

Div display :’block’;

conclusion

margin:’0 auto’; Applies only to block elements, and also sets the width property.

Note: img/input/button and other built-in width, can not be set.