This time I will bring you the unpopular method of centering elements horizontally and vertically. What are the precautions for centering elements horizontally and vertically? Here are practical cases, let’s take a look.
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> div{ position: absolute; width: 400px; height: 300px; background: pink; margin:auto; left:0; top:0; right:0; bottom: 0; } </style></head><body> <div></div></body></html>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!
Related reading:
Notification bar script startup tool written in Python
Using flv.js and video.js A live video effect
How to use canvas to make it easy to use Graffiti drawing board
How to use js-xlsx to merge cells
The above is the detailed content of Unpopular method to center elements horizontally and vertically. For more information, please follow other related articles on the PHP Chinese website!