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 397,783 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 2,422 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
Views: 15227 | Replies: 28
Reply
Join Date: Aug 2006
Location: braintree
Posts: 57
Reputation: bazmanblue is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bazmanblue bazmanblue is offline Offline
Junior Poster in Training

How to have the div layer center on any browser?

  #1  
Nov 2nd, 2006
hello im trying to get my div layer to align so that it centers on the browser so it doesnt matter about the size of somones browser it will always be centered on the page. i have tried
[HTML]<div align="center" class="style1" id="Layer1">[/HTML]
but this doesnt seem to work when i view it in my browser and make the browser page smaller. i am doing this in dreamweavers test browser, could this be the problem? any help would be very much apreciated
To get 1000 links to free ad sites visit
http://www.freeaddsgalore.me.uk
For FREE:!:
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: Utrecht, The Netherlands
Posts: 9
Reputation: BudBrocken is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
BudBrocken BudBrocken is offline Offline
Newbie Poster

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

  #2  
Nov 2nd, 2006
align=center doesn't work on divs.
try this:

body {
    text-align: center;
}
.style1 {
    margin: auto auto;
}
www.rozengain.com - Web Development Blog
Reply With Quote  
Join Date: Aug 2006
Location: braintree
Posts: 57
Reputation: bazmanblue is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bazmanblue bazmanblue is offline Offline
Junior Poster in Training

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

  #3  
Nov 2nd, 2006
thanks but i have tried that and this way but it still doesnt work for some reason
[HTML]#Layer1 {
position:absolute;
width:800px;
height:800px;
margin-right:auto;
margin-right:auto;
}[/HTML]
is it the position absolute that i need to delete? might try that now
To get 1000 links to free ad sites visit
http://www.freeaddsgalore.me.uk
For FREE:!:
Reply With Quote  
Join Date: Aug 2006
Location: braintree
Posts: 57
Reputation: bazmanblue is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bazmanblue bazmanblue is offline Offline
Junior Poster in Training

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

  #4  
Nov 2nd, 2006
nope not the position absolute either:rolleyes:
To get 1000 links to free ad sites visit
http://www.freeaddsgalore.me.uk
For FREE:!:
Reply With Quote  
Join Date: Oct 2006
Location: Utrecht, The Netherlands
Posts: 9
Reputation: BudBrocken is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
BudBrocken BudBrocken is offline Offline
Newbie Poster

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

  #5  
Nov 2nd, 2006
indeed, it won't work with absolute positioning
www.rozengain.com - Web Development Blog
Reply With Quote  
Join Date: Oct 2006
Location: Utrecht, The Netherlands
Posts: 9
Reputation: BudBrocken is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
BudBrocken BudBrocken is offline Offline
Newbie Poster

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

  #6  
Nov 2nd, 2006
use
margin: auto auto;
don't use
margin-right: auto;
margin-right: auto;
and don't forget
body {
    text-align: center;
}
Last edited by BudBrocken : Nov 2nd, 2006 at 10:37 am.
www.rozengain.com - Web Development Blog
Reply With Quote  
Join Date: Aug 2006
Location: braintree
Posts: 57
Reputation: bazmanblue is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bazmanblue bazmanblue is offline Offline
Junior Poster in Training

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

  #7  
Nov 2nd, 2006
aha thanks your a star! do you know how i keep the divs inside this div from moving?
i.e there left and top attributes?
To get 1000 links to free ad sites visit
http://www.freeaddsgalore.me.uk
For FREE:!:
Reply With Quote  
Join Date: Aug 2006
Location: braintree
Posts: 57
Reputation: bazmanblue is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bazmanblue bazmanblue is offline Offline
Junior Poster in Training

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

  #8  
Nov 2nd, 2006
ive got the main layer to staycentral thanks. but how do i keep the layers on top of this in the same position on that layer when the browser size changes?
To get 1000 links to free ad sites visit
http://www.freeaddsgalore.me.uk
For FREE:!:
Reply With Quote  
Join Date: Aug 2006
Location: braintree
Posts: 57
Reputation: bazmanblue is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
bazmanblue bazmanblue is offline Offline
Junior Poster in Training

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

  #9  
Nov 2nd, 2006
this is how i have set the layers over another layer
[HTML]<div class="style1" id="Layer1"><img src="dmlayer1.png" width="800" height="800" />
<div id="Layer7"></div>
<div id="Layer6"></div>
<div id="Layer5">
<div align="left"> </div>
</div>
<div id="Layer4">
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="501" height="115">
<param name="movie" value="dmtitle.swf" />
<param name="quality" value="high" /><param name="LOOP" value="false" />
<embed src="dmtitle.swf" width="501" height="115" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>
</object>
</div>
<div id="Layer2">
<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="150" height="150">
<param name="movie" value="fruitdm.swf" />
<param name="quality" value="high" />
<embed src="fruitdm.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="150" height="150"></embed>
</object>
</div>
</div>[/HTML]

and this is how one of the layers is currently set out in css

[HTML]#Layer3 {
position:absolute;
width:200px;
height:115px;
z-index:2;
left: 314px;
top: 32px;
background-color: #FFFFFF;
}[/HTML]
To get 1000 links to free ad sites visit
http://www.freeaddsgalore.me.uk
For FREE:!:
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

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

  #10  
Nov 2nd, 2006
In all of this discussion, "doctype" hasn't been mentioned. It is impossible to tell you what HTML/CSS code to use if we don't know which version of HTML/CSS you're using.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 4:59 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC