PDA

View Full Version : Default Layer Writing Question


mark4man
01-06-2007, 05:54 PM
People...

An internet friend of mine in another forum helped me solve a parent (container) layer centering problem. I had created a large layer ("Layer 1")...nested Layers 2, 3 & 4 within Layer 1...& wanted Layer 1 to slide to the center of any browser window, with 2,3 & 4 not changing absolute position relative to Layer 1. The solution was:

<div id="Layer1" style="position:relative; width:285px; height:311px; margin: 0 auto;">
<div id="Layer2" style="position:absolute; width:47px; height:115px; z-index:1; left: 226px; top: 120px;"><img src="layer2.jpg" width="58" height="133"></div>
<div id="Layer3" style="position:absolute; width:131px; height:115px; z-index:2; left: 3px; top: 3px;"><img src="layer3.jpg" width="158" height="189"></div>
<div id="Layer4" style="position:absolute; width:176px; height:71px; z-index:3; left: 94px; top: 130px;">;"><img src="layer4.jpg" width="158" height="189"></div>
</div>

[w/ divs 2, 3 & 4 tabbed (inset) two spaces to define nesting]

where the container (Layer 1) was assigned relative positioning & centered by auto margins...& the nested layers (2,3 & 4) remained absolute; & inline

...but...

...he also tells me that inline styles are not a good idea.

Everybody tells me that inline styles are not a good idea.

But no one tells me why.

So...3 questions:

1) Why are inline styles not a good idea...& is that relative (pardon the pun) to the way I am now centering my layer layout?

2) Is there a way to configure Dreamweaver to write layer code (i.e., user draws in the layer...Dreamweaver writes the code) other than inline?

3) On all of my existing page layouts that consist of multiple layers (each one housing an image or text)...that I now want centered...how do I now nest those layers in a large container layer? (the above centering solution was from a test page I created from scratch...& the subsequent layers were nested as I went. I now need to go back to existing pages & center the layout.)

Thanks very much,

mark4man
Dreamweaver MX (6.0)

ramandeep
01-11-2007, 10:09 PM
Hi Mark4man,

I will try to answer your questions step wise step
1) Inline styles, why not?
Yes inline styles is not good practice to use in your pages. As per rule we should seperate content from presentation , using inline styles are like using <font> tags to me.

Say for example you used inline tags in your pages and in a later stage you wish to make presentational changes, you will have to make changes in all the pages.

and if you use external CSS file than just that file only.

2) As far as i know there is no special way to configure Dreamweaver to write layer code, but yes you should know how to use layers effectively. Try using layers for layouts and you will master this in sometime.

3) For centering your designs you can use 2 methods which i use normally

<div id="wrapper">
</div>


a) Using Auto margins

#body{
text-align:center; /* for IE */
min-width: 760px; /* for Netscape */
}
#wrapper{
width:740px; /* make it fit well in 800X600 resolution*/
margin:0 auto;
text-align:left;
}


b) Using positioning and negative margins

#wrapper{
width:740px;
position: relative;
left: 50%
margin-left:-360px;
}