I’m new to coding. I’m trying to center the content of my body using and .wrapper in CSS. The CSS border, color etc is showing up but I can’t seem to make center my content.
Here’s what I’m trying:
.wrapper {
max-width: 1280px;
background-color: beige;
margin: 0 auto;
border: 1px solid black;}
I know I could probably use other ways to center the wrapper, but shouldn’t this work in theory? lol
2
Answers
Okay!, You want to center the div.wrapper horizontally and vertically.
You can use the CSS Flex Property.
The element is centered. The problem is that the block elements take all the available width from left to right, so you can’t see if it’s centered or not.
some common block elements are p and div tags.
Try reducing the max-width amount as per your need, you will see that it’s centered.
And another solution is putting all the elements that should be centered in a center tag.