|
#1
| ||||
| ||||
| changing a css statement depending on the reuslt of $_GET['page']
I have a site tabbed navigation at the top, this is done by CSS, every tab has a off state, and an on state the on state for each tab is the same. the content is controlled by a $_GET['page'] statement, is there a way to change the state of a tab depending on the result of $_GET['page']? for example if $_GET['page'] returns 'services' then the services tab is highlighted (with its on state) and every other tab is 'off'? I will post an example when i iorn out a few cracks. \ Edit: added link : http://adambrowndesigns.co.uk/dev/si....php?page=home Also how do i set it to always default to viewing home.html when i open the site? Last edited by Browni; April 19th, 2005 at 11:13 AM. Reason: Addling link |
|
#2
| ||||
| ||||
|
i know exactly what you want. you want to have tabs that highlight on mouse (using :hover) but also you want the current page's tab to be highlighted all the time. there isn't a way that i know of to do it, without duplication. ie: in the css file, declare another class for each tab, in the "on" state (highlighted, or whatever) and then add a string into the class="" paramater in the HTML, using a php variable..
__________________ PowerMac G5 Dual 2.0Ghz | 1Gb | 250Gb | Bluetooth | NVidia GeForce 6800 Ultra DDL 256Mb | 20" Cinema Display | MX1000 Wireless Laser Mouse | OS X 10.3.9 PowerMac G4 400Mhz | 832Mb | 40Gb + 120Gb | OS X Server 10.3.8 - Web Dev, Proxy, Mail, NAT, Firewall, Backup Netgear Gigabit Switch | Sony Ericsson P910i Smartphone | iPod Colour 60Gb |
|
#3
| ||||
| ||||
|
Very simple to do with CSS and a simple body id tag, no PHP required. HTML: Code: <body id="nav_services"> <a href="index.php?page=home" class="nav_services">Home</a> Code: #nav_services #menu .nav_services {
color: #000;
border-top: 1px solid #666;
border-right: 1px solid #666;
border-bottom: 1px solid #fff;
border-left: 1px solid #666;
background-color: #fff;
background-image: none;
{
You might want to consider using an unordered list to control the links better too. CSS example for all links: Code: #nav_home #menu .nav_home,
#nav_services #menu .nav_services,
#nav_support #menu .nav_support,
#nav_itunes #menu .nav_itunes,
#nav_gallery #menu .nav_gallery,
#nav_contact #menu .nav_contact {
color: #000;
border-top: 1px solid #666;
border-right: 1px solid #666;
border-bottom: 1px solid #fff;
border-left: 1px solid #666;
background-color: #fff;
background-image: none;
{
__________________ . | mdnky@macosx.com | My Homepage | My Music | Restore the Pledge | MacOSX.com Widget | • MacBook Pro Core2Duo 2.33GHz 15", 2GB DDR2 RAM, 500GB 7200RPM, DL Superdrive, OS X 10.6, • Apple 23" Cinema HD Display, Apple Slim-Alum Keyboard, Apple BT Alum Keyboard, Logitech Optical Scroll Mouse • iPhone 3G, iPhone 8GB, iPod Photo 30GB, Nikon D50, Nikon L6, Epson 3490, Epson R1800, HP LaserJet 1200 • LaCie 500GB d2 Quadra, LaCie 160GB d2 FW, harman/kardon SoundSticks II, Mighty Mouse, iSight Last edited by mdnky; April 19th, 2005 at 08:59 PM. |
|
#4
| ||||
| ||||
|
mdnky is right about everything. I agree about using a ul for the tab list too - it's a more sensible way to represent a list. Just make sure to use display: inline;
__________________ 15" MacBook Pro Mac OS X v10.5.1 2.33GHz, 2GB RAM, 120GB HDD 5G iPod 60GB |
|
#5
| ||||
| ||||
|
that would make it __________ as aposed to | | | | Right? |
|
#6
| ||||
| ||||
|
Yea. Either display inline, or display block on the li elements with a float: left specified, will do the job (make sure to clear the float if you choose that method).
__________________ . | mdnky@macosx.com | My Homepage | My Music | Restore the Pledge | MacOSX.com Widget | • MacBook Pro Core2Duo 2.33GHz 15", 2GB DDR2 RAM, 500GB 7200RPM, DL Superdrive, OS X 10.6, • Apple 23" Cinema HD Display, Apple Slim-Alum Keyboard, Apple BT Alum Keyboard, Logitech Optical Scroll Mouse • iPhone 3G, iPhone 8GB, iPod Photo 30GB, Nikon D50, Nikon L6, Epson 3490, Epson R1800, HP LaserJet 1200 • LaCie 500GB d2 Quadra, LaCie 160GB d2 FW, harman/kardon SoundSticks II, Mighty Mouse, iSight |
|
#7
| ||||
| ||||
|
i really need to learn so me CSS and stop relying on Dreamwever to do it for me, because i have very little idea with it.
|
|
#8
| ||||
| ||||
|
Best way to learn it is to do it; as the more you do it, the easier it'll become. Be prepared to be annoyed for a short period while you transition over from the 'old-ways' of thinking and doing things, but that'll disappear shortly and everything will be brighter. It's kinda like switching from Windows to Mac OS X...not totally, but kinda like that. Some books that might be worth looking into: You can find a lot of info on the web itself. Just have to be careful who you listen to on the web sometimes. Designer's Sites to Browse: xHTML & CSS resource sites: xHTML & CSS showcases:
__________________ . | mdnky@macosx.com | My Homepage | My Music | Restore the Pledge | MacOSX.com Widget | • MacBook Pro Core2Duo 2.33GHz 15", 2GB DDR2 RAM, 500GB 7200RPM, DL Superdrive, OS X 10.6, • Apple 23" Cinema HD Display, Apple Slim-Alum Keyboard, Apple BT Alum Keyboard, Logitech Optical Scroll Mouse • iPhone 3G, iPhone 8GB, iPod Photo 30GB, Nikon D50, Nikon L6, Epson 3490, Epson R1800, HP LaserJet 1200 • LaCie 500GB d2 Quadra, LaCie 160GB d2 FW, harman/kardon SoundSticks II, Mighty Mouse, iSight |
![]() |
| Bookmarks |
| Thread Tools | |
|
|