With two <p>
elements nested under an <h1>
element, my goal is to ensure that the width of the displayed paragraphs never exceeds 90% of the content width within the header. The content of both <p>
and <h1>
elements is dynamically generated on the server side via Django and may wrap on smaller screens.
Experimenting with d-flex
, flex-column
, and flex-shrink
has yielded some success, although I have struggled to maintain responsive resizing of the <p>
elements while also centering all three elements horizontally within the parent container div.
<div class="container">
<div class="text-center">
<h1 class="display-4">A Brief Yet Bold Title!</h1>
<p class="lead">This sentence could potentially be longer than the title above. Nevertheless, its width should not exceed 90% of the h1 tag's width.</p>
<p><i>While this sentence might be shorter, I still want to limit its width accordingly.</i></p>
</div>
</div>