View Full Version : Dynamic CSS
benconnekt
11-18-2011, 12:42 PM
How do I make the css background colour of the home page different from the inner pages. The home page bgcolour is black and looks good with the design but doesn't look nice on the inner pages, so I would like to make the inner pages while or a better colour.
How can this be achieved?
ajfmrf
11-18-2011, 03:41 PM
You need to post the page with the problem so people can look at the source to help you.
this is not "dynamic" css; it's just a different rule. the easiest way would be to add an id or class attribute to the <body> of the page in question, like so:
<!--home page-->
<body class="blackBG">
<!--other pages-->
<body>
/* css stylesheet */
body{ background: #fff; } /* white background is the default */
body.blackBG{ background: #000; } /* black background for specific pages */
benconnekt
11-18-2011, 07:21 PM
Thanks guys for your responses..Here's the link. This is an open cart template.
http://london-webdesigners.com/demo/nwhairsnglamour
benconnekt
11-18-2011, 08:38 PM
I have sorted it with PHP. However, if theres a shorter way of achieving this, your constructive contribution will be appreciated.
<?
$url="http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if ($url == "homepageurl" ){?>
<style>
#content{
background: black;
}
</style>
<? } else {?>
<style>
#content{
background: white;
}
</style>
<? } ?>
my suggestion above is much simpler and far more efficient. Also, do you realize that that page takes almost 20s to load (first view/no cache)? Even after I had the images cached, it took 6.
have a look (http://www.webpagetest.org/result/111118_8T_27M7M/)
benconnekt
11-21-2011, 02:15 AM
Thanks Traq for your observation, I think that has to do with my hosting account cos it loads up normally locally. If not I would have to look at the coding properlly, Im really new in developing open cart
local viewing will of course be very quick - it's local. The files don't have to go anywhere because they're already on your computer. The rest of the world might not want to hang around and wait, however.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.