Ask Your Question
3

What advanced CSS properties can I use to align my div to the center of my web page?

asked 2022-01-24 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-12-28 18:00:00 +0000

scrum gravatar image

You can use the following advanced CSS properties to align a div to the center of the webpage:

  1. display: flex; justify-content: center; align-items: center;

  2. position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);

  3. text-align: center; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);

  4. margin: auto; position: absolute; top: 0; bottom: 0; left: 0; right: 0;

All of these CSS properties will work to center a div on a webpage. The one you choose will depend on the layout of your page and the specific requirements of the design.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-01-24 11:00:00 +0000

Seen: 14 times

Last updated: Dec 28 '21