Hello all, I'm new to Stack Overflow and I hope I'm following all the guidelines correctly.
I am currently facing a challenge with positioning divs in a manner similar to a Skype chat window. While there are methods for aligning three divs (left, center, right) or two divs on the left side, aligning two divs on the right side together has proven to be quite tricky, especially when one of them doesn't have a fixed size.
So far, I've managed to position the incoming user's profile picture, chat bubble, and timestamp successfully, but I'm struggling with positioning the outgoing message.
Due to my numerous attempts at finding the right solution, the current code is messy. Any help that can set me on the right path would be greatly appreciated.
This image showcases the design I'm aiming for: Skype chat window
This is the HTML structure for incoming messages:
<div class="skype-parent">
<img class="skype-in-avatar" src="users_avatar.jpg alt="" />
<div class="skype-in-message">
This is the incoming text.
</div>
<div class="skype-timestamp">
08:42
</div>
</div>
Here is the HTML structure for outgoing messages:
<div class="skype-parent">
<div class="skype-out-message">
This is the outgoing text.
</div>
<div class="skype-timestamp">
08:56
</div>
</div>
CSS for parent div (working as intended):
div.skype-parent {
text-align: left;
margin-top: 0.2em;
margin-bottom: 0.2em;
clear: both;
}
CSS for timestamp div (working as intended):
div.skype-timestamp {
text-align: center;
margin-top: 0.5em;
float: right;
}
CSS for incoming messages (working as intended):
img.skype-in-avatar {
float: left;
width: 30px;
height: 30px;
margin-left: 0.5em;
margin-right: 0.5em;
border-radius: 1.5em;
}
div.skype-in-message {
max-width: 75%;
background-color: #c7edfc;
padding: 0.5em;
border-radius: 10px;
display: inline-block;
vertical-align: bottom;
}
CSS for outgoing messages (not functioning correctly):
div.skype-out-message {
max-width: 75%;
background-color: #e5f7fd;
padding: 0.5em;
border-radius: 10px;
}
My main issue lies in positioning the outgoing message element. I need assistance in getting the chat bubble to align to the right while still being situated to the left of the timestamp, as shown in the example mentioned above.