PDA

View Full Version : Does anyone have a problem like mine?


Mai
12-02-2010, 06:56 PM
When I change something for example- text, images or sizes of each box (header, content or slideshow area) in the index page, the other page will be effected. I only copied (save as) one page and found out this problem when I was trying to change different information on the new page. I assume it's cause from the CSS rules because when I made another page and applied the layout to the code (html) then it was fine.

I am new for dreamweaver CS4.

Mai
12-03-2010, 03:50 PM
Could anyone help me to fine the answer?

DWcourse
12-03-2010, 04:15 PM
If you have your CSS styles in a separate file that is linked to your page, then changing the style rules will affect all the pages that link to that style sheet (that's the power of CSS).

However that should only affect the appearance of the page not the content of the page.

Corrosive
12-03-2010, 05:38 PM
You sure you are not using a template?

Mai
12-03-2010, 06:52 PM
To. DWcours, you mean if I want to have the "home page" one look and the other pages have another look then I should have CSS file separately for each apprearance. I thought I could have only one CSS file for an entire site with multiple looks of pages. What I am doing is only "Home" different than the others.

Thank you very much for replying and the answer!
**********************************

To. Corrosive, I builded the web site from the scratch. If the correct answer is the different apprearance of each page has to have its own CSS file then I got it.....I feel so light...thank you.

Corrosive
12-03-2010, 07:36 PM
Sorry, I think you are missing the point somewhat. CSS is used to control the layout (not content) of your website from one file so you don't have to have only one stylesheet but you really should try and limit it to one. If you have different stylesheets for each page then you have defeated the object of them.

Web design is about consistent layout in my book so your look and layout is controlled by the stylesheet and then your content is added afterwards. Think carefully about your layout and how you will achieve a good looking site with the minimum of code and how you will separate style from content.

DWcourse
12-04-2010, 01:42 AM
If you want the home page to look different you will need different css style rules for that page. But the rules can be in the same file and a lot of rules will probably be applicable to both files (font styles, etc.). If you give the body tag of your home page a unique id, <body id="home"> for instance. You can target only that page by putting #home in front of the style rule name.

So the rule

#home p {
fot-size: 14px;
}

would apply only to paragraphs on the home page not to paragraphs on any other page.

If you have multiple pages that share a special rule you can apply a class to the body tag of those pages such as <body class="special">
so that any rule beginning with the class name such as

.special p {
fot-size: 14px;
}

will apply to all pages with the special class applied to the body tag. In this case the rule would apply to paragraphs on all page with the special class applied.

Mai
12-06-2010, 05:33 PM
Thank you very much for you both, Corrosive and DW course.

Now I see the point. What my understanding from your explanations is that in practical I can have more than one CSS file but the most efficient is one and in that file I can target only that page by putting #home in front of the style rule name like what DW course said (special thank for your explanation, it's really clear but I still don't know much about the codes).

How about if I choose "this document only" at Rule Definition (at a new CSS rule window) instead of "Layout.css"(the CSS file) for the target. Is that possible to fix this problem? Perhaps it's another option for me to do so.:mrgreen:

Corrosive
12-06-2010, 05:40 PM
Yes, 'this document only' will put your CSS styles between your <head> tags and will apply to only that page. Make sure that is what you want and that you won't need that style anywhere else in the site :)

Mai
12-06-2010, 06:12 PM
Hi Corrosive,
I really appreciate for your reply and answer.:grin:
Many thanks!

It seems that is the best solution for me for now.:mrgreen:

DWcourse
12-07-2010, 04:23 AM
But you still want to give the new styles names that will overwrite the existing style rules (or if you use the same names make sure that your in page style rules appear after the link to your off page style sheet)

Mai
12-09-2010, 03:48 PM
Hi DWcourse,
I am still interested in your previous suggestion about creating a specific name for the target for example "<body id="home">". Could you explain more about this? Should these codes go to between <head> or <body>tag? And If they go to between < body> _ </body>, and where should it be (..after "wrapper")?

I see some websites, (all) the pages share the same basic foundation, only the different parts (such as images or other different looks) go to between <head>tag of each individual page. Is this the same idea or similar as your suggestion?

Thank you very much for helping me!

DWcourse
12-09-2010, 04:02 PM
In DW, if you select an object (either on the page or by selecting its tag from the list in the status bar at the bottom of the document window) you can name it by typing a name into the ID filed in the Properties Inspector. That automatically inserts the ID attribute into the tag. You can then use that ID as a selector in the CSS style rule name.

So, if you give the body tag the ID of home., placing #home (the # indicates the selector is and ID) before the rest of the rule name, the rule will apply ONLY to objects within the tag with the ID of home (in this case anything on the home page since the body tag wraps all the other tags). So this rule:

#home div p {
color: red;
}

Would make all paragraphs that are within a div and on the home page (and only those paragraphs) red.

Mai
12-10-2010, 05:17 PM
Hi DWcourse

I think I figure it out how to do it! :smile:


Thank you very very much!

Merry Christmas & Happy New Year!