I want to achieve the same text effect (little margins beneath the white boxes as shown in the blue box [1]
) in the green box [2]
. The green box [2]
must use flexbox (or css-grid) for layout.
My question is: Is this possible without changing the HTML-Code (eg. by adding a <span>
-element)?
/* =======================
General Styles (not relevant) */
section {
min-height: 15em;
font-family: sans-serif;
line-height: 1.4;
padding: 1em;
margin-bottom: 1em;
}
h2 {
display: inline;
background: white;
font-size: 1em;
margin-bottom: 0.5em;
}
/* ======================= */
/* Layout [ 1 ]: Just a little padding on the left */
section#one {
padding-left: 50%;
background: darkblue;
}
/* Layout [ 2 ]: Using flexbox */
section#two {
display: flex;
justify-content: flex-end;
align-items: baseline;
background: seagreen;
}
section#two h2 {
flex-basis: 50%;
}
<section id='one'>
<h2>[ 1 ] Lorem ipsum dolor sit amet, consetetur sadipscing elitr ut labore et dolore magna aliquyam erat, sed diam voluptua. </h2>
</section>
<section id='two'>
<h2>[ 2 ] Lorem ipsum dolor sit amet, consetetur sadipscing elitr ut labore et dolore magna aliquyam erat, sed diam voluptua. </h2>
</section>