How to center the width and height of unknown elements in CSS horizontally and vertically?

Parent element winth: 10%, child element winth: 100% (on the basis of the parent element, it is the same size as the parent element, how can it be centered relative to the parent element Cui Zhi?

The child element is absolutely positioned, 50% from the top, 50% from the left, and then use css3 transform: translate(-50%; -50%) to achieve -- "Advantages: tall, can be used in webkit core browsers , Disadvantage: The transform attribute is not supported below IE9

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325126915&siteId=291194637