Jump to content
Sign in to follow this  
Guest amr.ramadan

Relativity Theory: DIVs and FONTs

Recommended Posts

Guest amr.ramadan

Hi,I am a little bit confused, and frustrated, trying to design the layout of a page. The confusion comes from the fact that I am not sure if I am doing what I am doing the way it should be done.Now I have a div section, that has a specific size, and is positioned relative to the page. Inside that div, I want to place several divs containing text. Those inner divs - containing the text - SHOULD BE aligned relative to the top-left corner of their parent div. Now the problem is, as I understand it, relative alignment is relative to the last cursor position.Put it another way. I have two divs inside the parent, and I want them to be located at (20,40) and (50,60), relative to the top-left corner of their parent, how can I do that?When I approached this problem, I solved it by stupidly hacking the position of each text div, for example, the first would be (20,40) and I use trial and error till I find that the correct position requires the second be (-15,15), or whatever.Although this works perfectly in all browsers, it is dependant on the font size, which in turn is dependant on the actual font. I am using Verdana, nothing fancy, but thing didn't turn quite good when I tested the page on Linux (Firefox 1.0.3). It replaced the font with another, and went utterly ugly, scattering everything everywhere.Is their a solution to this limitation. I thought that putting each div in a separate z-index would allow me to position each div relative to the top-left corner of the parent, but apparently this doesn't work!!Please, heeeelpp... :)

Share this post


Link to post
Share on other sites

I could probably help you more if I could see an example, but I'll try anyway. It sounds like you might already know to do this... but I figure I migth as well say it:set the first div style to:position:relative;left:20;top:40;set the second div style to:position:relative;left:50;top:60;now... when the text changes size, it sounds like you want those value to change. This is always a problem. One option is to set the numbers to percents, but you can never get it to work perfectly. There's some nasty stuff you can do with javascript. And then there's just redesigning the site to either not set positons or set all font sizes to absolute px values.hope that helped =/

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...