-1

I have looked but the answers that people have given didn't help my problem. Rather confusion. I am creating a small project for my website and i am trying to convert it to php for the pages and easier maint.

The way i want it set up is like how i have it now. Soloentertainment.org But this is all html and each page is it own Html page and if i need to edit or add to the nav bar or anywhere else i have to go to each html and change it. That is a big no no. So trying to convert it to php but the problem i have encountered, which is weird is that i have it highlight what page you are on now. But for the php, Soloentertainment.org/index.php, (i don't have all links working so the projects page and bout leads to the html links) but the home should be highlighted like in the original home page.

Code for the index.php:

<body bgcolor="#000000" id="home">
    <div align="center">
        <table class="contentTable" >
            <tbody>
                <tr>
                    <td colspan="0" border="0" height="50px" align="center">
                        <?php include("message.php"); ?>
                    </td>
                </tr>
                <tr>
                    <td colspan="0" border="0" height="125px" align="center">
                        <?php include("header.php"); ?>
                    </td>
                </tr>
                <tr>
                            <?php include("navbar.php"); ?>
                </tr>
                    <?php include("home.php");?>

            </tbody>
        </table>
    </div>
</body>

Code for the Navbar.php:

                <td id="navbar">
                        <ul>
                            <li onclick="location.href='http://www.soloentertainment.org/index.php';" class="home" title="Home">Home</li>
                            <li class="projects" title="Projects">Projects</li>
                            <li class="about" title="About">About</li>
                            <li>Contact</li>
                        </ul>
                </td>

The original index.html:

<!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" />
<link rel="shortcut icon" href="favicon.ico">
<title>Solo Entertainment</title>
</head>
<style>
.contentTable {
width: 795px;
border-left: 10px;
border-left-color: #b7ad6f;
border-right: 10px;
border-right-color: #b7ad6f;
margin: 0px;
padding: 0px;
}
.header {
background-color; #000
background-repeat: no-repeat;
background-position: right;
}
#navbar {
width:100%;
height:30px;
background-color:#000;
}

#navbar ul {
width:50%;
margin:0 auto 0 auto;
}

#navbar ul li {
float:left;
color: #FFF;
padding:0 20px 0 20px;
border:1px solid #FFF;
height:30px;
list-style:none;
display:block;
line-height:30px;
text-align:center;
cursor:pointer;

}

#navbar ul li:hover {
background-color:#CCC;
color: #000;
}

#home #menu .home, #projects #menu .projects {
background-color:#FFF;
color: #111
}


</style>
<body bgcolor="#000000" id="home">
    <div align="center" id="menu">
        <table class="contentTable">
            <tbody>
                <tr>
                    <td colspan="2" border="0" height="55px" align="center">
                        <font color="#FF0000" size="+2">This site is still being built. Please be Patient</font>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="header" align="left" border="0" height="125px">
                        <img src="images/solo.png" width="785" height="112" alt="Title" title="Solo Enertainment" border="0">
                    </td>
                </tr>
                <tr>
                    <td id="navbar">
                            <ul>
                                <li onclick="location.href='http://www.soloentertainment.org';" class="home" title="Home">Home</li>
                                <li onclick="location.href='http://www.soloentertainment.org/projects';" class="projects" title="Projects">Projects</li>
                                <li onclick="location.href='http://www.soloentertainment.org/about';" class="about" title="About">About</li>
                                <li>Contact</li>
                            </ul>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" class="header" align="center" border="0" height="100px">

                        <font color="#FFFFFF" size=""> Welcome to Solo Entertainment, One Man One Show.</font>

                    </td>
                </tr>
                                 <tr>
                    <td colspan="2" class="header" align="Center" border="0">

                        <img src="./images/kyleandsteve1280.jpg" width="307" height="245" />
                        <br />
                        <font color="#FFFFFF">Kyle and Steve Save the world.
                        <br />
                        </td>
                </tr>


            </tbody>
        </table>
    </div>
</body>
</html>

Now the i don't get why Home is highlighted in the html and not for the php?

4

1 回答 1

2

Your css that make the highlight looks like this:

#home #menu .home, #projects #menu .projects {
    background-color: #FFFFFF;
    color: #111111;
}

On your PHP file, the button with .home class is under an element with a #home id but there's no element with #menu id.

This is the part on your HTML:

<body bgcolor="#000000" id="home">
<div align="center" id="menu">

This is the part on your PHP:

<body bgcolor="#000000" id="home">
<div align="center">
于 2013-08-18T12:53:53.447 回答