My idea is to make each element within div
s that have the .main_content
class, to have a width equal to the width of the text inside it. How do I this?
As you can see, the width of each one (span
, h2,
p
and h6
) is the same as the .main_content
div
. The red border demonstrates this.
So, how do I make the width of each div fit the text within those divs? (With only CSS)
.main_content {
width: 100%;
height: 400px;
font-weight: 800;
}
.main_content > * {
border: 1px solid red;
display: block;
margin-bottom: 30px;
text-align: center;
}
<div class="first_article">
<div class="first_content">
<div class="main_content">
<span class="growth">Growth</span>
<h2>5 compelling user referral campaign examples</h2>
<p>Jumpstarts your user referral engine with these 5 approaches toreferral campaigns from popular apps.
</p>
<h6>Author</h6>
</div>
</div>
</div>
P: I've been trying to manually set the size of width
of each element. But there is too much code. Is there any clever way to to this?