I've recently discovered the use of pseudo elements as graphical elements for design purposes. I'm trying to use a ::after
element on a div to create horizontal dividers between sections, below:
.banner {
position: relative;
width: 100%;
overflow: hidden;
}
.banner__text, .banner__logo {
width: 50%;
float: left;
}
.banner::after {
content: '';
position: absolute;
left: 0;
right: 0;
border-bottom: 1px solid purple;
}
<div class="app">
<div class="banner">
<div class="banner__text">
<h3>Hello World</h3>
<p>longer string here</p>
</div>
<div class="banner__logo">
<img src="//unsplash.it/159/250" />
</div>
</div>
<div class="banner">
<div class="banner__text">
<h3>Hello World</h3>
<p>longer string here</p>
</div>
<div class="banner__logo">
<img src="//unsplash.it/159/250" />
</div>
</div>
<div class="banner">
<div class="banner__text">
<h3>Hello World</h3>
<p>longer string here</p>
</div>
<div class="banner__logo">
<img src="//unsplash.it/159/250" />
</div>
</div>
</div>
However, you will notice that all the ::after
elements stack right up at the top; is there a way I can have these absolutely positioned elements that have relatively positioned parents come after each div.banner
?
Note: this question ::after pseudo element appearing before has such a specific answer I cannot determine the solution, although it is similar in scope...
UPDATE
Adding overflow: hidden
to .banner
fixes the after elements stacking up at the top, but they still appear before the rest of the content in each div.banner
, while I'd like them after.