grungefreak Posted June 19, 2009 Share Posted June 19, 2009 This may not be the way to do things, but i developed a template for my website and the main content is class - .mainContent. On one of my pages, I would like to place a border around this class but I don't want it on other pages. Is there any way I can do this other than changing it to a div as this would have further repurcussions in the CSS file. GF Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/ Share on other sites More sharing options...
trq Posted June 19, 2009 Share Posted June 19, 2009 Just define you css styles within the file in question. Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/#findComment-859540 Share on other sites More sharing options...
grungefreak Posted June 19, 2009 Author Share Posted June 19, 2009 I know but I want to keep all my CSS in one external file. gf Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/#findComment-859551 Share on other sites More sharing options...
trq Posted June 19, 2009 Share Posted June 19, 2009 Well if you want to define one rule for one page you can't. Make sense? Just define everything in one page except override this one rule in the page that requires it. Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/#findComment-859555 Share on other sites More sharing options...
dgoosens Posted June 19, 2009 Share Posted June 19, 2009 just add a second class with border .withBorder { border: 1px solid black; } and in your page <span class="maincontent withBorder"> Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/#findComment-859557 Share on other sites More sharing options...
haku Posted June 20, 2009 Share Posted June 20, 2009 Add an ID to the body for that page. So if the page is 'about_us', you have: <body id="about_us"> Then to target that page you use #about_us .mainContent { // definitions for that page } Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/#findComment-859925 Share on other sites More sharing options...
dbrimlow Posted June 20, 2009 Share Posted June 20, 2009 haku's solution is the right one. It is a very cool trick, too. This is how you can get your navbar links to recognize and emulate "on-page" using CSS only. Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/#findComment-860270 Share on other sites More sharing options...
grungefreak Posted June 20, 2009 Author Share Posted June 20, 2009 haku's solution is the right one. It is a very cool trick, too. This is how you can get your navbar links to recognize and emulate "on-page" using CSS only. Yep, that's great. Thanks. GF Quote Link to comment https://forums.phpfreaks.com/topic/162898-solved-target-a-specific-class/#findComment-860282 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.