Im currently trying to build a banner with the tagline( 30 years of discovery) to be centered under the title text with a light grey background only around the text. I’m able to have the text centered with a grey background spanning my entire screen. I am also able to have a colored background on just the text as long but without the text being centered on my screen.
.tagline {
font-weight: 300;
display: inline-flexbox;
justify-content: center;
align-items: center;
text-align: center;
background-color: rgba(100, 89, 95, 0.75);
}
<div class="tagline">
<p> 30 Years of Discovery</p>
</div>
I would appreciate any insight that could be offered!
I’ve tried placing <p>
in a span, which is where I was able to just have a background color on text. This didn’t allow for me to center the div.
3
Answers
You should use
display: inline-block
otherwise if it is consideredblock
it is 100% width by default.I don’t know if this is what you want but something like this?
Css:
Html: