如何保留CSS按钮颜色

时间:2011-05-28 21:08:33

标签: css

我的css代码是:

.horizontalcssmenu ul{
    margin: 0;
    padding: 0;
    list-style-type: none;
    list-style:none;
}

.horizontalcssmenu ul  a:active{
    color: #00FFFF;
    background: #FF0033;
    text-decoration: none;
}

/*Top level list items*/
.horizontalcssmenu ul li{
    position: relative;
    display: inline;
    float: left;
    height: 34px;
    top: 25px;
    left: 111px;
    width: 71px;
    margin-left: 0px;
}

.horizontalcssmenu ul li a:active{
    color: #00FFFF;
    background: #FF0033;
    text-decoration: none;
}

/*Top level menu link items style*/
.horizontalcssmenu ul li a{
    border-left: 2px solid #202020;
    border-right: 2px solid #202020;
    border-top: 2px solid #202020;
    border-bottom: 2px solid #202020;
    display: block;
    width: 54px; /*Width of top level menu link items*/
    padding: 2px 8px;
    text-decoration: none;
    background: url(menubg.gif) center center repeat-x;
    color: Red;
    font: bold 13px Tahoma;
    height: 27px;
    margin-left: 0px;
}

/*Sub level menu*/
.horizontalcssmenu ul li ul{
    left: 0;
    top: 0;
    border-top: 1px solid #202020;
    position: absolute;
    display: block;
    visibility: hidden;
    z-index: 100;
}

.horizontalcssmenu ul li ul a:active{
    color: #00FFFF;
    background: #FF0033;
    text-decoration: none;
}

/*Sub level menu list items*/
.horizontalcssmenu ul li ul li{
    display: inline;
    float: none;
}

.horizontalcssmenu ul li ul li a:active{
    color: #00FFFF;
    background: #FF0033;
    text-decoration: none;
}

/* Sub level menu links style */
.horizontalcssmenu ul li ul li a{
    width: 100px; /*width of sub menu levels*/
    font-weight: normal;
    padding: 2px ;
    background: #663300;
    border-width:  1px 1px 1px;
}

.horizontalcssmenu ul li ul li a:active{
    color: #00FFFF;
    background: #FF0033;
    text-decoration: none;
}

.horizontalcssmenu ul li a:hover{
    color: #0066FF;
    background: #FF0033;
    text-decoration: none;
}

.horizontalcssmenu ul li a:active{
    color: #00FFFF;
    background: #FF0033;
    text-decoration: none;
}

.horizontalcssmenu ul li ul li a:hover{
    color: #00FFCC;
    background: #CCCC66
}

.horizontalcssmenu .arrowdiv{
    position: absolute;
    right: 1;
    background: transparent url(image/bg-bubplastic-button.gif) no-repeat center left;
}

* html p#iepara{ /*For a paragraph (if any) that immediately follows menu, add 1em top spacing between the two in IE*/
    padding-top: 1em;
}

/* Holly Hack for IE \*/
* html .horizontalcssmenu ul li { float: left; height: 1%; }
* html .horizontalcssmenu ul li a { height: 1%; }
/* End */

当用户移动到指定页面时,按钮颜色应该更改并保持不变,只要他在该页面中。我怎么能这样做?

2 个答案:

答案 0 :(得分:4)

您只需使用<body>标记id代码,然后从那里制作CSS选择器。示例:http://css-tricks.com/id-your-body-for-greater-css-control-and-specificity/

答案 1 :(得分:1)

你想要实现的目标没有css选择器链接状态。你应该使用一些Php检查你所在的页面并在

之后立即设置按钮的样式