I am implementing a chat for my web app and I find difficulty in placing the messages correctly and I am not skilled in CSS. I want to place the owner's messages to right and the other user's on the left.
Here some sample code:
// this is the container
<div className="container">
{messages.map(({ text='', isOwnMessage=false })=> <Message text={text} isOwnMessage={isOwnMessage}/>)}
</div>
// This is the message component
//...
<div classname="message">{text}</div>
I need to place <Message /> component to left if isOwnMessage is false, on the right otherwise. I know It can be done by giving position absolute and right:0 but that's not good for me. I tried as well: marginLeft: '50%' but then there's a problem with the dimension of the message itself, which is max 80% of the container, otherwise is like its content.
So how would you do that?