0

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?

2

2 Answers 2

2

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
}
Sign up to request clarification or add additional context in comments.

2 Comments

the content on each page is very basic so I am including it in the body element Can I still change the body class easily ?
I like to do <html class="<?php echo $pageClass ?>"> where $pageClass is populated beforehand or being drawn from the database along with the page. +1
0

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">

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.