#snackbar {
min-width: 350px; /* Default minimum width */
margin-left: -125px; /* Center value of min-width */
background-color: #333; /* Black background color */
color: #fff; /* White text color */
text-align: center; /* Centered text */
border-radius: 2px; /* Rounded borders */
padding: 10px; /* Padding */
position: fixed; /* Positioned on top of screen */
z-index: 1; /* Z-index option */
left: 85%; /* Snackbar centered */
bottom: 85%; /* Positioned 30px from the bottom */
}
<div id="snackbar">
Message 1
</div>
<div id="snackbar">
Message 2
</div>
<div id="snackbar">
Message 3
</div>
These elements combine into a single element where only message 3 is displayed, but I want them to stack on top of each other.
I tried to fix it with:
#snackbar ~ #snackbar {
margin-top: 10%;
}
However, this attempt did not successfully stack them under each other as intended.