How to align div element in code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to align div element in code?

Actually I made some box using div but how I align it in css to center,left or right.Please help me.

13th May 2019, 1:07 PM
Ankit Kumar
Ankit Kumar - avatar
3 Answers
13th May 2019, 3:29 PM
Sanjay Kamath
Sanjay Kamath - avatar
+ 1
You have to get styles to parent element of this div. For example: <div class="parent"> <div>Hey</div> </div> .parent { text-align: center; /* or left, right */ } P.S. If you want to get vertical align then you should get the parent div flexible display (display: flex;) P.S.S. Display: flex; - is very flexible to use)
13th May 2019, 5:02 PM
Sanzhar Baizhumanov
Sanzhar Baizhumanov - avatar
0
Please give me another way
13th May 2019, 4:39 PM
Ankit Kumar
Ankit Kumar - avatar