Forum Moderators: open

Message Too Old, No Replies

Positioning text "relatively"

         

Adam_C

6:51 pm on Nov 7, 2002 (gmt 0)

10+ Year Member



Does anyone know if it's possible to have a block of text, say within some <div> tags for example, at the top of your page (immediately under the <body> tag), that you would like to appear at some point further down the page as it appears on screen, without using absolute positioning? I'm aware of relative positioning as well, but that doesn't really help in this case.

Basically, my page has an outer table with height set to 100%, and an inner table with the real page content (height="700px"), so that the page appears in the middle of the screen for higher resolutions.

I want the body text at the top of my code, but to appear within a table cell lower down. Possible?

Longhaired Genius

7:33 pm on Nov 7, 2002 (gmt 0)

10+ Year Member



Boy Oh Boy!

I've read you question twice and I think I understand it well enough to know that I don't want to touch it.

Except to say that I think you're making life too complicated for yourself. Making tables by hand for positioning purposes is Not Sensible; if I were you I would use css margins for this. It's almost never a good idea to set the height of anything to 100%.

The most important thing is to get your content onto the web in a readable and navigable form first, then you can relax and learn presentation and positioning tricks at your own pace.

what I'm trying to say is: take the line of least resistance. If an approach seem too problematic, stop banging your head against a brick wall and try a simpler approach.

Hope that helps...

moonbiter

7:35 pm on Nov 7, 2002 (gmt 0)

10+ Year Member



Er, let me see if I understand you correctly.

You are using a table cell to position content on the page so that it at the center. Yet you don't want that content to be in that table cell, but in a different element altogether at the top of the page? Yes?

If this is the case, why are you using the table cell at all? If you are trying to use the td to position content, that content has to be within the it.

May I ask why you don't want to use absolute positioning? You can use it to put your content anywhere you want on the page.

Adam_C

10:25 pm on Nov 7, 2002 (gmt 0)

10+ Year Member



I thought this might be a tricky one!

We want this site to be centred vertically and horizontally to suit all screen resolutions. The text is to appear in the main section of the site/screen (i.e. in the middle).

As far as the source code goes, ideally I want this text to be as close to the top as possible - immediately under the <body> tag if possible.

Beginning to think a new approach might be needed.

BTW, I think absolute positioning would be out of the question as the vertical displacement varies with screen res'.

Nick_W

10:49 pm on Nov 7, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I don't want to touch i

Me neither! Sounds like a nightmare of 'dodgy design' -- no offence intended adam_c I'm no artist ;)

If you choose to go for the nested table, fixed 'window' approach you've pretty much gotta live with the fact that short of some outrageously complicated and fragile coding you'll never do it....

So, it's either back to the drawing board or rethink your design...

Personally I get really mad when I see a little window in the middle of my screen.

Liquid Design Baby! [webmasterworld.com]

Nick

moonbiter

6:10 am on Nov 8, 2002 (gmt 0)

10+ Year Member



BTW, I think absolute positioning would be out of the question as the vertical displacement varies with screen res'.

Well, if it wasn't for that pesky 700px height requirement and the fact that NN 4.x and (oddly) Opera don't display it right, you could do something this:

body {
height: 100%;
}
div#content {
position: absolute;
background: #FFF;
border: #333;
width: 70%;
height: 70%;
top: 15%;
left: 15%;
overflow: auto;
}

Note that, assuming the div is a child node of the body element, you have to give the body a height of 100% to get IE to display correctly in standards-compliant mode. This is because to use a percentage value for height on an element, it's parent node needs to have an explicitly set height property [msdn.microsoft.com].