How to put content of 2 divs at the same line height?

How to put content of 2 divs at the same line height?

Postby devidation » Sat May 17, 2014 5:33 pm

Hello,
For a project I'm doing I have made a chatbox.
However I would like to implement things like /time to hide/show the time of the message.
Therefor I have a a div for the time and a div for the messages.
The problem is that, if I send or receive a message that is longer than 1 line the time isn't on the same
height as the message anymore.
Is there an easy solution to fix this?
Thanks in advance.
devidation
 
Posts: 6
Joined: Thu May 08, 2014 2:03 pm

Re: How to put content of 2 divs at the same line height?

Postby stranac » Sat May 17, 2014 5:48 pm

Divs don't really sound like python...
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1151
Joined: Thu Feb 07, 2013 3:42 pm

Re: How to put content of 2 divs at the same line height?

Postby Yoriz » Sat May 17, 2014 6:24 pm

Not knowing what a div is, the easiest solution would be to not send or receive a message that is longer than 1 line.
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 871
Joined: Fri Feb 08, 2013 1:35 am
Location: UK

Re: How to put content of 2 divs at the same line height?

Postby Crimson King » Sat May 17, 2014 7:33 pm

@Yoriz: I believe he/she is referring to this div.

How are you using python to create this chatbox? Would you mind posting some code to better understand your problem?
User avatar
Crimson King
 
Posts: 118
Joined: Fri Mar 08, 2013 2:42 pm
Location: Buenos Aires, Argentina

Re: How to put content of 2 divs at the same line height?

Postby mnutz » Mon May 19, 2014 9:44 pm

A div is just a container that CSS uses to format the layout of a webpage.

Without seeing an example of the layout it is incredibly hard to distinguish what exactly is needed.

Personally I think you would be better having just one div for the chat and a then 2 radio buttons for turning time on or off.

You would need to read which radio button is ticked, then use that status to add the timestamp to the start of the actual chat sentence.

'Time off' would result in "this is a chat string", but 'time on' would result in "[TIME]This is a chat string"

That way there's no need to worry about formatting the time div.

However, if you must, then you could see how many characters in a chat string makes 1 line, then you'd have to divide the characters in the string by the line length to see how many lines you have. Then add a \n for each line in order to keep it equal.

If that makes sense :D
mnutz
 
Posts: 10
Joined: Sun Nov 17, 2013 8:11 am


Return to Web Development

Who is online

Users browsing this forum: No registered users and 1 guest