PHP generated inline CSS query
-
I’ve borrowed some code from this support forum so that I can generate an inline CSS style for the specific page a person is on. The navigation button is highlighted depending on what page of the site you’re on. I use this code to style the specific list element using inline CSS:
<?php
if ( is_home() ) { $current = 'b-home a'; }
elseif ( is_page('about') ) { $current = 'b-abou a'; }
elseif ( is_page('about-the-author') ) { $current = 'b-abou a'; }
elseif ( is_page('about-the-site') ) { $current = 'b-abou a'; }
elseif ( is_page('brief-resume') ) { $current = 'b-abou a'; }
elseif ( is_page('archive-index') ) { $current = 'b-arch a'; }
elseif ( is_page('links') ) { $current = 'b-link a'; }
elseif ( is_page('contact') ) { $current = 'b-cont a'; }
?><style type="text/css">
li#<?php echo $current;Â ?> {
color: #fff;
font-weight: bold;
background: #62C061 url(/img/nav-focus.gif) repeat-x bottom left;
}
</style>As im no expert on PHP what and where do I add to this code to style my list elements if $current is none of these options/pages. eg. a comment page? I dont want any of my navigation buttons highlighted on most of the other pages so the site actually works correctly as it is – the only problem is it wont validate. Basically that means i only need the inline CSS on my main web pages.
Hope that makes sense to someone! Thanks in advance!
The topic ‘PHP generated inline CSS query’ is closed to new replies.