+ 1
How do I centre this logo
11 Respostas
+ 2
Bring it to both x axis and y axis center:
Edit: Img 2 may have it off center
https://code.sololearn.com/WLns0n1kvajF/?ref=app
+ 2
Please could you bring it to both x axis and y axis centred?
+ 2
For demonstration purposes
<center><img src=" alt=" border="0" width="30%" id="img"></center>
Since the center tag was removed in HTML5, it is recommended that you use the CSS text-align property to format the text horizontally in the document.
<p> <img src=" alt=" border="0" width="30%" id="img"> </p>
p {
text-align : center;
}
+ 2
Chris Coder , had no idea that would work. Thx for sharing!
+ 2
Alexandre Yes if you have not learned about flex yet, it works. But maybe flex is a better solution.
+ 2
Wow.. thank you all
+ 2
Dharmendra Kumar go back and select the Green [+ New Post ] button
+ 1
Well, i don't know if that's what I should be using, but I normally use margin:auto, and put display flex to the parent element
https://code.sololearn.com/Wnzhrym279vK/?ref=app
+ 1
Oh, then I recommend you going here.
https://stackoverflow.com/questions/1776915/how-can-i-center-an-absolutely-positioned-element-in-a-div
+ 1
body {
display:flex;
justify-content:center;
align-items:center;
height:100vh;
}
body element only takes the size of content , to expand it to the size of visible document , i have set height to 100 vh .
Don't need width since it's a block element and also setting display : flex still makes it behave like a block element.
The other three properties above height are usually what i find the easiest way to center something.
0
How can i start my own Q&A