+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 14
Like Tree3Likes

Thread: How to make this (PHP CSS )

  1. #1
    medina's Avatar
    medina is offline x10 Addict medina is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Cuernavaca
    Posts
    1,837

    Red face How to make this (PHP CSS )

    Hi...

    I have a simple question in the PHP or CSS area.

    I always wanted to knowhow to make a selectable menu...
    for example i have the typical horizontal menu:

    Home Services Portafolio blah blah Contact

    (imagine this in the header of the web )

    I want to know how to make when i stay in the home section the word HOME of the menu make an appearance that is selected to be in bold text or a color effect... and when go to Contact section make the same effect, but the word home in the menu remove the effect and has the same effect than the others, only it is highlighted in the section I am ...

    Sorry for the bad language
    ▐ Quieres Ganar $50 dólares totalmente gratis en menos de 24 horas? Visita este Post y ve como lograrlo
    http://x10hosting.com/forums/mercado/124800-gana-0-35-por-ser-mi-referido-unos-50-00-extra.html






  2. #2
    medina's Avatar
    medina is offline x10 Addict medina is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Cuernavaca
    Posts
    1,837

    Re: How to make this (PHP CSS )

    ????.... no answer???
    ▐ Quieres Ganar $50 dólares totalmente gratis en menos de 24 horas? Visita este Post y ve como lograrlo
    http://x10hosting.com/forums/mercado/124800-gana-0-35-por-ser-mi-referido-unos-50-00-extra.html






  3. #3
    SJ.Wolfe's Avatar
    SJ.Wolfe is offline x10 Elder SJ.Wolfe is an unknown quantity at this point
    Join Date
    Aug 2010
    Location
    Washington, U.S.A.
    Posts
    590

    Re: How to make this (PHP CSS )

    It depends on how your menu is laid out HTML wise. Let's say your menu is done like this:

    Code:
    <div id="menubar">
      <span><a href="url.com/">Home</a></span>
      <span><a href="url.com/blog">Blog</a></span>
      <span><a href="url.com/about">About</a></span>
    </div>
    Then, with CSS, you could create a hover effect with this:

    Code:
    #menubar span {
      font-weight: normal;
      color: gray;
    }
    
    #menubar span:hover {
      font-weight: bold;
      color: white;
    }
    #menubar span tells the stylesheet to make the specified changes only to 'span' elements located inside of elements with the id attribute of 'menubar'.

    the :hover pseudo-class tells the style to apply the effects only when the specified element is hovered over.

    font-weight determines the 'weight' of the text (i.e., bold, normal in this case)
    color is the font color.
    SJWolfe - Volunteer Community Customer Service Representative
    Do NOT PM me, email me, or leave me a profile comment requesting support - Create a support ticket.
    Livewire's Slave - Wielder of the Finely Dressed Pimp Slap
    Join us on IRC! irc.x10hosting.com:6667 #publicchat

  4. #4
    essellar's Avatar
    essellar is online now Community Advocate essellar has a spectacular aura about
    Join Date
    Feb 2010
    Location
    Toronto, Ontario, CA
    Posts
    1,152

    Re: How to make this (PHP CSS )

    I believe what Medina is looking for is a persistent "you are here" indicator rather than (or in addition to) hover effects. That would involve changing the class of the menu link either at the PHP level (good, but sometimes difficult to implement when using "shrinkwrapped" software) or using JavaScript (not so good, but often easier to extract from a URL before any rewrite rules are in effect).

    The CSS is simple; making the class change depends on how and where the menu and the site's pages are generated. More info is needed.

    In any case, this question is in the wrong forum, which is why I ignored it initially -- it belongs in the Programming Help section.
    “Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
    "It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)

  5. #5
    leafypiggy's Avatar
    leafypiggy is offline Community Advocate leafypiggy is on a distinguished road
    Join Date
    Aug 2007
    Location
    Massachusetts
    Posts
    2,228

    Re: How to make this (PHP CSS )

    Gonna throw out some really tough shorthand PHP for you, but this is basically what you want:

    [php]
    <a href="#" <? echo ($page=="home") ? "class='active'" : null; ?> >Home</a>

    And essentially, repeat this for each menu link, and at the top of that page, declare the $page variable. What the PHP does is checks if the $page variable is equal to "home" and if it is, assigns it "class='active'", which you can handle in your CSS to be bold, etc.

    If you're using a CMS, this is a lot harder to handle, and will involve this PHP, and a lot more thinking.

    If you're just using flat HTML and stuff, you don't even need php. Just edit the particular page and add "class='active'" to the link you want to be in it's "active" or hover state.

    I've done what I did with PHP on my website:

    http://neilhanlon.com/home

    Notice how the navbar link is bold when you change the page. I used a /very/ simple templating system to do this, and just included my header and footer through PHP after assigning the variables, such as title and page.

    Sorry if this doesn't make sense.. I'm on drugs for my foot currently
    medina likes this.
    Neil Hanlon | x10Hosting Support Representative
    Neil[at]x10hosting.com
    █ I'm always happy to help. Just ask a question in Free Hosting
    Terms of Service IRC

  6. #6
    medina's Avatar
    medina is offline x10 Addict medina is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Cuernavaca
    Posts
    1,837

    Re: How to make this (PHP CSS )

    Yeah... im not looking for a hover effect!...essellar is right!...

    @ leafypiggy
    I think you're right, I'll try later, but a lot of logic because what you said ...
    ▐ Quieres Ganar $50 dólares totalmente gratis en menos de 24 horas? Visita este Post y ve como lograrlo
    http://x10hosting.com/forums/mercado/124800-gana-0-35-por-ser-mi-referido-unos-50-00-extra.html






  7. #7
    medina's Avatar
    medina is offline x10 Addict medina is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Cuernavaca
    Posts
    1,837

    Re: How to make this (PHP CSS )

    sorry for my little knowledge

    but not work for me, is very logical, but what I was told I would be grateful if you could help me with an example to see .... would be very grateful

    PHP Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <style>
    #active{
        color:#0F0;
        }
    .active{
        color:#0F0;
        }
    </style>
    </head>

    <body>

    <div id="menuhoriz">  
    <ul>  
            <li><a href="?id=home" <? echo ($id=="?id=home") ? "class='active'" null?> >Home</a></li>  
            <li><a href="?id=contact" <? echo ($id=="?id=contact") ? "class='active'" null?> >Contact</a></li>  
    </ul>  
    </div>  

    <?php 

    if(!isset($_GET['id']) || $_GET['id'] == 'index' || empty($_GET['id'])) { 
        if (
    file_exists('inicio.php')) { 
            include(
    'inicio.php'); 
        } 
        else { 
            if(
    file_exists('error.php')) { 
                include(
    'error.php'); 
            } 
            else { 
                echo 
    "ERROR: No se encuentra una Portada para el sitio"
            } 
        } 

    else { 
        if (
    file_exists($_GET['id'].'.php')) { 
            include(
    $_GET['id'].'.php'); 
        } 
        else { 
            if(
    file_exists('error.php')) { 
                include(
    'error.php'); 
            } 
            else { 
                echo 
    "Error ?".$_SERVER['QUERY_STRING']; 
            } 
        } 


    ?>
    </body>
    </html>
    is this ok?...
    Last edited by medina; 07-02-2011 at 01:33 PM.
    ▐ Quieres Ganar $50 dólares totalmente gratis en menos de 24 horas? Visita este Post y ve como lograrlo
    http://x10hosting.com/forums/mercado/124800-gana-0-35-por-ser-mi-referido-unos-50-00-extra.html






  8. #8
    Gonrah's Avatar
    Gonrah is offline x10Hosting Member Gonrah is an unknown quantity at this point
    Join Date
    Sep 2010
    Location
    Earth
    Posts
    95

    Re: How to make this (PHP CSS )

    Do you use PHP on your site or only HTML.

  9. #9
    medina's Avatar
    medina is offline x10 Addict medina is an unknown quantity at this point
    Join Date
    Nov 2006
    Location
    Cuernavaca
    Posts
    1,837

    Re: How to make this (PHP CSS )

    Yeah... sure is a .php extension!...
    ▐ Quieres Ganar $50 dólares totalmente gratis en menos de 24 horas? Visita este Post y ve como lograrlo
    http://x10hosting.com/forums/mercado/124800-gana-0-35-por-ser-mi-referido-unos-50-00-extra.html






  10. #10
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: How to make this (PHP CSS )

    are the pages home.php contact.php about.php etc? or index.php?x=home index.php?x=contact etc?
    Nothing is always absolutely so.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. trying to make a few changes
    By doobz in forum Programming Help
    Replies: 4
    Last Post: 10-02-2008, 11:29 AM
  2. make me a sig
    By Smurf in forum Graphics & Webdesign
    Replies: 9
    Last Post: 02-22-2006, 12:10 AM
  3. I just want to make sure
    By AllStarGamer101 in forum Free Hosting
    Replies: 2
    Last Post: 12-09-2005, 07:32 PM
  4. Make Your Own CMS
    By o0slowpaul0o in forum Tutorials
    Replies: 10
    Last Post: 08-27-2005, 03:10 PM
  5. How to make something like...
    By wizeman in forum Free Hosting
    Replies: 3
    Last Post: 08-09-2005, 12:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers