dotNes
dotNes

Reputation: 85

Change css class with php multi pages

I have a multiple pages website where I wan't to change some css stuffs. So my index.php?p=page points to various pages but on every page I also want to adjust some css like the color of the currently active menu item(li) etc.

What is the best way to achieve this? Should i just make a php var on each page?

Upvotes: 0

Views: 474

Answers (2)

Diodeus - James MacFarlane
Diodeus - James MacFarlane

Reputation: 114447

One way to handle this is to put a class on the BODY tag for each page, then make different subclasses for the stuff that changes. This way you don't need to feed in any variables from PHP. It's all done via CSS.

<body class="pageOne">

CSS:

.pageOne h1 {
    color:#ff0000
}

.pageTwo h1 {
    color:#000000
}

Upvotes: 2

bfavaretto
bfavaretto

Reputation: 71939

You should have the CSS on an external file, and link it using a <link> tag, like so:

<link rel="stylesheet" type="text/css" href="path_to_stylesheet.css">

Upvotes: 0

Related Questions