I am trying to center a
I have done this using the following CSS which works, but the content inside isn’t centering.
I have attached a screenshot of what I mean.
This is my CSS.
Can anyone tell me why the content inside the
main-banner-text is not centered?
top: 0; left: 0; bottom: 0; right: 0;
/* vendor prefixes omitted due to brevity */
Hi there toolman,
we need to so see all the HTML and all the CSS.
That’s because you have no rules applied that will affect the content.
All you have is a rule for centering the whole element. You probably need to use flexbox instead and then can control both the element and it’s content.
You probably don’t need the absolute positioning either but without context it’s hard to tell.
If you give the relevant HTML and css as already asked I’m sure we can come up with the right solution
Thanks for the replies. I used
align-items: center to align the inner content
I just want to remind that OP wanted a vertical alignment.
(Besides, the text-align property only works for inline content, though it would affect text in flexbox too.)
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.