What is the CSS to have a DIV expand in length to fit the content put into it?
This DIV is going to contain the messages typed in by people, so the length of the DIV is to change based on length of message posted. FYI, we need this for a Node.js based Web chat we are creating.
You can see the simple sample of the chat room under dev here: www.sitesticky.com
So go ahead and type a short message and you will see it will display good.
But type in a long message and it breaks out of the DIV that is to contain it!
We have tried setting the length to auto 100% etc. and non worked.
Looking at the actual site, you have absolute positioning on the div which takes it out of the flow, remove that and it will be back in the flow and expand to take content.
Your suggestion does work to the extent that now the text message is all fit within the user chat message bubble (DIV).
But the reason we had the absolute positioning there was to keep the Text message to not wrap under the Avatar image of the user. So having removed the absolute positioning now long messages are wrapping under the Avatar image rather wrap nicely under the text message only which is what we want.
What suggestions do you have to achieve both results?
That is worse. Now the chat messages are under the Avatar image.
Also please keep in mind that the Chat room owner, their chat message (Text + Avatar) display on the right side of the screen. Visitors chat message (Text + Avatar) display on the left side. Hence we have:
avatar_place & text_place for visitors
&
avatar_place_owner & text_place_owner for the member (who owns this chat room) and invited people to chat
Hey, your code reduced works just fine! Cool.
When the messages are by visitors on the left side.
But when the chat messages are by the owner of the room, which means on the right side, it is not working as the Avatar image follows out the chat message bubble!
You can see it here in this sample chat room: