Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Content Positioning (again)

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
OK, so I found some code which allowed me to center the entire content of my web page. BTW all content is theoretically in one table, but various images etc. use absolute positioning, so making the table center leaves them in the same place. BUT if I specify the table to use absolute positioning as well I CAN move everything around. Here's the code I used to center the content:

<div style=&quot;position: absolute; top: 0; left: 50%; margin-left: -390; width: 780; height: 660&quot;>

This comes just after the background colour and links colour declaration and before the table html.

So basically the way it works is to move my content 1/2 the users SREEN SIZE to the right and then half the CONTENT back again (-390). So, the problem. Well, this works great for 800x600 resolution and above (BTW each page is designed to fill an 800x600 screen excatly), but on a 640x480 the content drifts into a negative position - off screen left. Does anyone have a solution, or is there some JavaScript which 'll do this properly?? There must be a solution it's rediculous - and no, I'm not going to redesign for 640x480 or add script to recognise a users screen size!!

Thanks for your help in advance
 
I don't really understand what you asking. If it is how to center objects for different screen resolutions you can put the object in between the <CENTER> </CENTER> tags. This will center objects in any resolution. Hardly anyone uses 640 x 480 anymore. If it goes off the screen it will have a scroll bar at the bottom. That's what it's for. Rob
Just my $.02.
 
The <center> tags don't work in this case. Also, the browser will not create a scroll bar to view right-hand off-screen content. Imagine selecting a whole table which contains text from extreme left to right then specify it as absolute postitoning and give it a negative 'left' value. If you preview that in a browser the content flowing on the left of the screen is simply not visible. It only allows scrolling for content which is running off the right of the screen.
 
Where did you find that strange code? Your problem could be that you have specified a width in pixels (780 is greater than 640). If Rob's suggestion of using the <CENTER></CENTER> tags don't work, and I can't see why they would not, try changing your pixels to percentages. eg &quot;margin left:-49%&quot; and &quot;width:98%&quot;. The percentages are not exact, but a 640x480 display should fit it within the parameters of the screen. It's worth a try.
 
Thanks for the suggestion Jeff, but that doesn't do what I want - it just ends up giving a margin of half the screen on the left and like I said, my content is designed to fill the width of a 800x400 screen. All I want to do is make it central for higher resolution screens, rather than being positioned on the left. The code I gave was written so there's a way of postitioning absolute objects in the center of browsers for all monitors, but as you say, it shifts the content by too many pixels for smaller screens. Also I believe that the <center> tags only work with relative positioning (or not with tables, anyway). I'll post my code in a new message cos' no one seems to see the problem! Thanks anyway
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top