0

所以,我想要发生的是,一旦按下菜单项,网站就会翻转到该页面,但通向该页面的按钮在该页面上保持活动状态,以向用户显示他们在网站上的位置. 到目前为止,我还没有找到一个有效的组合,我希望它可以完全与 css3 一起使用。

html

<div id="navMenu">
                <ul id="MenuBar1" class="MenuBarHorizontal">
                    <li><a href="index.html">&nbsp;HOME&nbsp;</a></li>
                    <li><a href="surveying.html">SURVEYING</a></li>
                    <li><a href="engineering.html">ENGINEERING</a></li>
                    <li><a href="companyProfile.html">COMPANY PROFILE</a></li>
                    <li><a href="products.html">PRODUCTS</a></li>
                    <li><a href="clients.html">CLIENTS</a></li>
                    <li><a href="contacUs.html">CONTACT US&nbsp;</a></li>
                </ul>
        </div>

css3

#navMenu {
    padding: 0;
    margin: 5% 0 0 0;
    text-decoration: none;
    font-family: arial;
    font-size: 16px;
    font-weight: normal;
    text-decoration: none;
}
#navMenuActive {
    position: absolute;
    height: 47px;
    padding: 0;
    background-color: red;
}
#navMenuActiveText {
    margin: 16px 0 0 0;
    padding: 0;
    color: #FFFFFF;
    text-decoration: none;
    text-align: center;
    font-family: arial;
    font-size: 16px;
    font-weight: normal;
}
ul.MenuBarHorizontal {
    width: 100%;
    alignment-baseline: central;
    margin: 0 0 0 0;
    padding: 0;
    padding-bottom: 5px;
    list-style-type: none;
    font-size: 100%;
    text-align: center;
    cursor: default;
    overflow: hidden;
    white-space: nowrap;
}
ul.MenuBarHorizontal li {
    height: 30px;
    display: inline-block;
    margin: 18px 0 0 0;
    padding: 0;
}
ul.MenuBarHorizontal a:link, ul.MenuBarHorizontal a:visited {
    padding:17px 23px 8px 23px;
    margin-top: 0px;
    margin-left: -.5px;
    margin-right: -.5px;
    text-align:center;
    text-decoration:none;
    text-transform:uppercase;
    color: #555;
    background-image: url(../images/navBar_i.png);
}
ul.MenuBarHorizontal a, ul.MenuBarHorizontal a:hover, ul.MenuBarHorizontal a:active {
    color: rgb(255,255,255);
    background-image: url(../images/navBar_a.png);
}
4

1 回答 1

1

在目标页面中,在指示用户所在页面的项目上放置一个类名,如“current”,

            <ul id="MenuBar1" class="MenuBarHorizontal">
                <li><a href="index.html">&nbsp;HOME&nbsp;</a></li>
                <li><a href="surveying.html">SURVEYING</a></li>
                <li class="current"><a href="engineering.html">ENGINEERING</a></li>
                <li><a href="companyProfile.html">COMPANY PROFILE</a></li>
                <li><a href="products.html">PRODUCTS</a></li>
                <li><a href="clients.html">CLIENTS</a></li>
                <li><a href="contacUs.html">CONTACT US&nbsp;</a></li>
           </ul>

和适当的风格。

   .current{font-weight:bold /* etc. */ }
于 2013-04-26T02:41:18.770 回答