#div:normal #div:hover #div:SELECTED?
On the "services" and "company" pages I have a right sidebar list. This is being included with PHP. So far I have a CSS class for normal and a CSS class for when you hover each item in the list. I want to have a new class for when开发者_StackOverflow中文版 each list item is selected. So for example in services, the user clicks on "family planning" and when they get to the family planning page....the family planning list item has a grey background. Is this possible?
http://beulahprint.ie/index.php
Cheers,
ColmNothing in CSS will let you match an element based on it's href attribute resolving to the current URL.
Add a class to the menu item (or the body element) server side based on the page, then use a write a selector to match that.
There are a few ways to accomplish this but you'll need a little bit of code. It works like follows:
- On your page you should somehow declare which page it is (by using a querystring or session)
- Then you should parse this value and write out the class name of the menu dynamiclly.
Yes it is possible, when rendering the sidebar/menu, check if they are in a specific page/namespace and add a class to it which has grey background.
The general design people use for such scenarios is to place all items related to one menu item in one namespace.
like all admin items will be under */admin/*
, so that when rendering the menu, they will check the url and add the class to it.
精彩评论