HighDots Forums  

centering

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss centering in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
-D-
 
Posts: n/a

Default centering - 05-20-2004 , 04:57 PM






I'm using the following method to center a page horizontally using CSS with
a container div:

body {
text-align: center;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
margin: 0px;
}
..center {
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
text-align: left;
}
#container {
width: 790px;
visibility: visible;
z-index: 1;
position: relative;
}

My question is whether there is a difference or any problems caused by not
setting absolute positioning for the the divs within the container div? For
example:

<body>
<div id="container" class="center">
<div><img src="images2/P3.gif"></div>
</body>


Secondly is there a way to vertically center the container div?
Thanks,
-D-



Reply With Quote
  #2  
Old   
Murray *TMM*
 
Posts: n/a

Default Re: centering - 05-21-2004 , 09:54 AM






Why not just do this -

body {
text-align: center;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
}
#container {
width: 790px;
visibility: visible;
z-index: 1;
position: relative;
text-align:left;
margin: 0 auto;
}

You don't need to use positioning for nested divs *UNLESS* you want them to
be located somewhere other than the flow of the code would do. As far as I
know, that's the only ramification/consideration.

Vertical centering is a challenge in CSS but you can try Gary's recent
proposal for fixed height elements -

top:50%;
top-margin:-<half the total height of the container>;

(that's a negative top margin)

--
Murray --- ICQ 71997575
Team Macromedia Volunteer for Dreamweaver MX
(If you *MUST* email me, don't LAUGH when you do so!)
==================
news://forums.macromedia.com/macromedia.dreamweaver - THE BEST WAY TO GET
ANSWERS
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================

"-D-" <noone (AT) nospam (DOT) com> wrote

Quote:
I'm using the following method to center a page horizontally using CSS
with
a container div:

body {
text-align: center;
font-family: "Times New Roman", Times, serif;
font-size: 12px;
margin: 0px;
}
.center {
margin-top: 0px;
margin-right: auto;
margin-bottom: 0px;
margin-left: auto;
text-align: left;
}
#container {
width: 790px;
visibility: visible;
z-index: 1;
position: relative;
}

My question is whether there is a difference or any problems caused by not
setting absolute positioning for the the divs within the container div?
For
example:

body
div id="container" class="center"
div><img src="images2/P3.gif"></div
/body


Secondly is there a way to vertically center the container div?
Thanks,
-D-





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.