User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 423,461 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,846 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

How to have the div layer center on any browser?

Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 35
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: How to have the div layer center on any browser?

  #25  
Nov 2nd, 2006
Again, start simple, as I've shown. Then add styles, as needed. All positions follow the box model, and cascade (Thus "Cascading" Style Sheets).

Continuing my example:

[html]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Sample Page</title>
<style type="text/css">
.container
{
width: 200px;
margin: auto auto;
}

.child
{
position: relative;
left: 40px;
}
</style>
</head>

<body class="container">
<div id="container" class="container">
<p>Some content to flesh out the div.</p>
<div id="child1" class="child"><p>A child div</p></div>
<div id="child2"><p>Another child</p></div>
</div>
</body>
</html>[/html]
Now you can see that one of the child DIV elements is positioned 40px to the left, relative to the parent DIV. Or, put another way, the position of the child element is determined by

1) The automatic margin of the parent DIV, which cascades down into the child divs, and
2) The "left" setting, 40px

I explain CSS Positioning in the linked article.

You seem oddly unwilling either to learn or to accept the help being offered, so this will be my last post in this thread. Soldier on.
Last edited by tgreer : Nov 2nd, 2006 at 6:23 pm.
Reply With Quote  
All times are GMT -4. The time now is 3:07 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC