-2

There is a class named gdiv in my style sheet which refer to the general div condition.
I can change my text alignment from gdiv. but can not change alignment of everything like div inside div. How can I align everything?

Nehax
  • 49
  • 9

2 Answers2

0

I think the best way to align the items to the center of your div, is to use flexbox

.gdiv {
   display: flex; /* just to set it to flex box */
   justify-content: center; /* to align the items horizontally in the div */
   align-items: center; /* to align the items vertically in the div */
}

if you want to align the DIV itself by its parent, you can use this code in the parent;

If what you want to align is a text, you can just use:

.gdiv {
    text-align: center;
 }

If you're beginner, i highly recommend you to study flexbox and grid in css!

Gabriel
  • 11
  • 1
-1

It is quite hard to give a solution without code. But flexbox should center everything inside a div, even other divs.

display: flex;
align-items: center;
justify-content: center;
MaZoli
  • 1,388
  • 1
  • 11
  • 17