25th Jun 2022, 6:02 PM
Tony Stark
Tony Stark - avatar
11 odpowiedzi
+ 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
25th Jun 2022, 6:46 PM
Chris Coder
Chris Coder - avatar
+ 2
Please could you bring it to both x axis and y axis centred?
25th Jun 2022, 6:17 PM
Tony Stark
Tony Stark - avatar
+ 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; }
25th Jun 2022, 6:20 PM
Chris Coder
Chris Coder - avatar
+ 2
Chris Coder , had no idea that would work. Thx for sharing!
25th Jun 2022, 6:32 PM
Alexandre
Alexandre - avatar
+ 2
Alexandre Yes if you have not learned about flex yet, it works. But maybe flex is a better solution.
25th Jun 2022, 6:34 PM
Chris Coder
Chris Coder - avatar
+ 2
Wow.. thank you all
25th Jun 2022, 6:48 PM
Tony Stark
Tony Stark - avatar
+ 2
Dharmendra Kumar go back and select the Green [+ New Post ] button
27th Jun 2022, 2:37 AM
Chris Coder
Chris Coder - avatar
+ 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
25th Jun 2022, 6:16 PM
Alexandre
Alexandre - avatar
25th Jun 2022, 6:19 PM
Alexandre
Alexandre - avatar
+ 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.
25th Jun 2022, 6:26 PM
Abhay
Abhay - avatar
0
How can i start my own Q&A
27th Jun 2022, 2:18 AM
Dharmendra Kumar