473,804 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Centering a layer in the window with CSS

is there some way to make the positioning of a layer (div) so that it
is centered in the window. so even when you resize the window it stays
centered? i would like to do this with CSS just like you can with
tables.

thanks,
~peter
Jul 21 '05
10 8797
*Frances Del Rio* <fd***@yahoo.co m>:
Peter Altenberg wrote:
is there some way to make the positioning of a layer (div) so that it
is centered in the window. so even when you resize the window it stays
centered?
I know some people will yell and scream that this is not orthodox way to
do it,


It is in fact a very "orthodox" way, the one from table layout days.
but this is what I do when I need to center a div and it always works
(IE and Netscape anyway..)
Strange definition of "always".
it does involve tables, but it's the only sure way I have found to
center divs, take it or leave it:
Then you didn't search well enough. Others have given the correct CSS
approach (the hack for IE5 with 'text-align' wasn't mentioned explicitely
AFAICS, but is described in almost all FAQ answers on this issue).
<div id="stuff" style="position :absolute; top:80px; left:0px">
<table border=1 cellpadding=0 cellspacing=0 width="100%">
<tr><td align=center>
\me is away vomiting.
if (navigator.user Agent.indexOf(' Opera') != -1 ) {
location = "version_of_pg_ for_Opera.html" }


Ew, it comes again.

--
If the glass is half full or half empty
depends on if you are pouring or drinking.
Jul 21 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2590
by: Erik Schulp | last post by:
Hi all, I am trying to get a CSS defined layout to center on the page, have tried doing this with the <center></center> tags but than everything is centered, including text etc etc. What should I put into the stylesheet so that, no matter what resolution the viewer's screen is set to, the layout is always displayed centered ? Erik Schulp
15
13508
by: red | last post by:
How do I center two side by side divs ? I've been writing css pages for a while but there's one thing tha still eludes me. I can center a div with margin auto. I can place two divs side by side with float. But I can't center two side by side divs. If I float them and give them auto margins, the auto margins are ignored. If I wrap the two floated divs in another div, the two divs have no
2
2614
by: kevinC | last post by:
Hello, I know most of you are probably going seeing positioning:absolute; and centering in the title and saying, oh no! not again! Do a google search! Actually, I've found many helpful resources online and realize that my case may be a bit more challenging. I'm trying to create a table-less layout that looks something like:
6
1924
by: news.versatel.de | last post by:
Hello NG, I am using javascript to open a new window like this: printpreview=window.open('printview.php','printprev','width=600,height=600'); The new window has a layer called preview: <div id="preview"></div>
17
2516
by: Applebrownbetty | last post by:
Hi, I'd like to append/amend the following code from the Dreamweaver extension "Open Picture Window Fever" for the ability to center the PopUp window: By default, it allows the window to be offset on the left and top, but does not include a centering option. I'm thinking it would include something like (screen.width-imageWidth)/2; somewhere but not sure how do go about doing this.
1
7032
by: vince.guzman | last post by:
Need help with showing Layer 4 after menu times out onmouseout _______________________________________________ <html> <head> <script language="JavaScript"> <!-- function mmLoadMenus() { if (window.mm_menu_0422101100_0) return;
4
1606
by: Paolo | last post by:
I would like to have it so that my webpages, which are built using MasterPages, always appear in the center of the browser of the user, even if he resizes the browser window. As a starting point, when creating the Masterpage, this is the generated html: <body> <form id="form1" runat="server"> <div>
3
4214
by: John Pote | last post by:
1. Horizontal centering a <divin browser window. The current trend seems to be to place page content in a fixed width area in the middle of the browser window. How is this achieved? If I use a top level <divthen I can place it with CSS attribute 'left:', but this is a fixed offset. Is it possible to have a <divcentered in the browser window? 2. Verticle centering in <div>
0
1031
by: Steve | last post by:
Hi... This code appears to work on the development box when centering and sizing a word application in front of the form that triggered the automation. But on the target boxes, it skews down and to the right. And the size of the word window is bigger than the form window that I'm calculating against (the word window should be .9 as wide and .8 as high). I think it may have something to do with the target box resolution or font size...
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9577
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10075
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9140
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.