(see "Update below" for a live demonstration of what I want)
I have an online game with a chat system, but CSS suck.
Example with images:



And two code examples.
Here I used the absolute value with the user's position, and we can talk about other speeches.
.speech-container {
position:absolute;
top:0;
left:0;
height:250px;
background:rgba(0,0,0,.15);
width:100%;
}
.speech {
background:white;
border:1px solid brown;
padding:10px;
border-radius:5px;
position:absolute;
}
<div class="speech-container">
<div class="speech red" style="left:20px;top:10px">
<span><b>User1:</b> Test</span>
</div>
<div class="speech red" style="left:20px;top:60px">
<span><b>User1:</b> Test</span>
</div>
<div class="speech blue" style="left:120px;top:10px">
<span><b>User2:</b> Hi</span>
</div>
<div class="speech blue" style="left:120px;top:60px">
<span><b>User2:</b> Hi</span>
</div>
<div class="speech blue" style="left:120px;top:110px">
<span><b>User2:</b> Testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt</span>
</div>
<div class="speech blue" style="left:120px;top:160px">
<span><b>User2:</b> Hi</span>
</div>
<div class="speech blue" style="left:20px;top:110px">
<span><b>User1:</b> Testtttttttttttttttttttttttttttttttttttt (pronounced after the user2 speech)</span>
</div>
<div class="speech blue" style="right:20px;top:15px">
<span><b>User3:</b> Test</span>
</div>
</div>
Run codeHide resultAnd the “what I need” demo
here I have what I want, but with absolute, is it impossible to use flex and absolute for a column system?
.speech-container {
position:absolute;
top:40px;
left:0;
height:250px;
background:rgba(0,0,0,.15);
width:100%;
}
.speech {
background:white;
border:1px solid brown;
padding:10px;
border-radius:5px;
position:absolute;
}
<div class="speech-container">
<div class="speech red" style="left:20px;top:10px">
<span><b>User1:</b> Test</span>
</div>
<div class="speech red" style="left:20px;top:60px">
<span><b>User1:</b> Test</span>
</div>
<div class="speech blue" style="left:120px;top:10px">
<span><b>User2:</b> Hi</span>
</div>
<div class="speech blue" style="left:120px;top:60px">
<span><b>User2:</b> Hi</span>
</div>
<div class="speech blue" style="left:120px;top:110px">
<span><b>User2:</b> Testttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt</span>
</div>
<div class="speech blue" style="left:120px;top:210px">
<span><b>User2:</b> Hi</span>
</div>
<div class="speech blue" style="left:20px;top:160px">
<span><b>User1:</b> Testtttttttttttttttttttttttttttttttttttt (pronounced after the user2 speech)</span>
</div>
<div class="speech blue" style="right:20px;top:15px">
<span><b>User3:</b> Test</span>
</div>
</div>
<b>What I expect, use flex maybe?</b>
Run codeHide resultUPDATE: I found the game with what I want (Habbo).
GIF:

How can i fix this?
source
share