Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the position property of css to center the box

Shulou Source: shulou.com Published: 2022-06-01 02:09:15 09月21日 Update

Editor to share with you how to use the position attribute of css to achieve box center, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Use the position property of css

.div1 {width: 100px; height: 100px; border: 1px solid # 000000; position: relative;} .div2 {width: 40px; height: 40px; background-color: red; position: absolute; margin: auto; top: 0; left: 0 Right: 0; bottom: 0;}

Effect picture:

The above is all the content of the article "how to use the position property of css to center the box". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Attributes articles boxes content not much most effects renderings more knowledge industry information information channels channels references learning help Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Microsoft macOS Redmi