We are developing a Node.js based Web chat and we want to have the Text message bubbles have a Width that expands and shrinks to the width of the actual message plus 5px for padding but for these DIVs to have max width that is 65%. Very much like how messages display on your iPhone.
Also these DIVs can be posted on left of screen and right of screen depending if you are the owner of the chat room. And for this solution to be Mobile friendly too so that people can chat on their iPhone as they can on their desktop via this Ch at service.
As you can see right now chat messages have a fixed width.
What CSS would take care off this?
Thanks,
P.S. The access to the Chat via above URLs is a hack to give you access to the chat so you may not be able to use all features of the chat that members accessing it right would, please ignore that.
To get the left / right posts I would maybe use floats because they too shrink width to fit content and by nature sit on either the left of right side.
But they do come with the added complication of requiring to be cleared, I fix that by giving each post an extra wrapper with a clearfix.
Then I just add an extra .owner class to the owner’s posts to change from the default left float to right.
Your suggestion works as far as the messages by guests to the chat room, that is messages posted to left via DIV
.msg_place
However msgs posted on right side via DIV
.msg_place_owner
are not set on the right side and are instead floating on the middle of the scrren as you can see from this screen shot
Seems like a float: right
took care of that right side placement!
Still have problems with messages running over member Avatar images. Working on that.
Problems remain as you can see from enclosed screen shot. That is once we get to the bottom of the page. Keep in mind to make the messages scroll up, we use this CSS code to append the messages:
var chatArea = document.getElementById("chat_area");
chatArea.scrollTop = messagesContainer.scrollHeight;
I think that will work, however I can’t seem to test it with user comments on the left too. Your links are for left posts, and right posts in separate pages.
It looks like you fixed that with right padding, that’s what I would have suggested.
Just to let you know, you have more problems then you may be aware of.
Your page starts to break apart when the viewport gets below 1000px. At 1000px the absolute positioned “Sound” buttton starts laying on top of your “Send” button.
Things get worse from there as the users in room (right) column starts to drop.
Yes, I know the Mobile version of the CSS code for this is not done yet.
I am working crazy on the core code of this chat service and to integrate it into the site.
Do you have the CSS code for making the chat UI Mobile friendly?
That would be highly appreciated