+ 1

How do I make aligning chat messages?

I thought this would be easy but I guess not... I want to align chat messages, when they show up they are not aligned correctly, they are in a line. I tried using margin but it's not working. The bot messages should float to the right and have even space in between each message, same for the user msg. https://code.sololearn.com/W1aXlHQlxI5g/?ref=app

11th Jul 2020, 11:37 PM
Coder
Coder - avatar
4 Answers
+ 3
Hira Ali ❀ hello, When you give a float:right every following element will come surrounding it (untill you use the clear property). As in your function you create every div with that property , each time it is called, the element is positioning that way. If you remove the float in usermsg class and modify text-align:right in pmsg class it will work as you want I think.
12th Jul 2020, 12:13 AM
EmmanueLZ.
EmmanueLZ. - avatar
+ 3
EmmanueLZ. Thank you!!
12th Jul 2020, 12:31 AM
Coder
Coder - avatar
+ 2
You're welcome. About your bot messages, i'm not sure how you'll handle its answers, so once you'll code a little more about that, feel free to ask again if there is some trouble.
12th Jul 2020, 12:42 AM
EmmanueLZ.
EmmanueLZ. - avatar
+ 2
EmmanueLZ. I got the JS figured out, but thank you.
12th Jul 2020, 1:34 AM
Coder
Coder - avatar