+ 1
How to center a div horizontally?
Please don't put margin:auto; for the answer because It doesn't work for me.
3 Respostas
0
What is the code you currently have?
0
Show your code, so we can see what you are trying to do. Because margin auto is what centers a div.
0
There are several ways to center a div element in HTML using CSS:
Using margin: auto and a fixed width:
https://code.sololearn.com/WWS48B9Sy9cu/?ref=app
Using display: flex and justify-content: center:Using display: grid and place-items: center:
https://code.sololearn.com/WHewXnpSkUOo/?ref=app
Using display: grid and place-items: center:
https://code.sololearn.com/WlZuG06RSFDI/?ref=app
Using display: table and margin: 0 auto:
https://code.sololearn.com/WHPX3krVX6cL/?ref=app
Using position: absolute and left: 50%, top: 50%, and transform: translate(-50%, -50%):
https://code.sololearn.com/W52qUxTHVqgg/?ref=app