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
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;
}
+ 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>
+ 1
Thanks so much Gavin Christians, it worked :'D