0

Problem with "display" in CSS

I want to align a image to the center of a page using CSS, but when i use display:center; it doesn´t work. I dont know if i'm using the wrong word, but it happens always and I always have to align it using margin-left and margin-top. Please i need someone to tell me how it can be happening. Thanks :D

21st Mar 2017, 4:26 PM
Ángel Daniel
Ángel Daniel - avatar
3 Respuestas
+ 2
Try using "text-align:center;" on the container that contains the image. Example (HTML and CSS): //The HTML part <body> <img src="#" alt="test"/> </body> //The CSS part body { text-align:center; }
21st Mar 2017, 4:32 PM
Ghauth Christians
Ghauth Christians - avatar
+ 1
Hello, the display isn't made for that ! if you want to align an element you can use this : css : .center { margin: 0 auto; position: relative; } html : <div class="center"> the content </div>
21st Mar 2017, 4:36 PM
Jérémy BOURGIN
+ 1
Thanks so much Gavin Christians, it worked :'D
21st Mar 2017, 4:40 PM
Ángel Daniel
Ángel Daniel - avatar