![](/img/trans.png)
[英]How to change active tab background color as selected tab without click?
[英]How to change the Selected tab Color in CSS
這是我的Tabs CSS代碼。 單擊選項卡時,選項卡顏色應該會更改。
/* #tab1 */
.custom #tabbuttons .tab1 a { background: #F6F6F6; color: #1C94C4; } /* override UI Theme */
.custom #tabbuttons .tab1 {background:#006699}
.custom #tabbuttons .tab1 a:hover{background: #FDF5CE;color:#FF0000}
.custom #tabpanels #tab1,
.custom #tab1 .ui-layout-resizer-sliding ,
.custom #tab1 .ui-layout-west , /* sidebar panes too - for when 'sliding' */
.custom #tab1 .ui-layout-east { background: #4794D8; }
.custom #tab1 .ui-layout-resizer-closed { border: 1px solid #4cbf52; }
.custom #tab1 .toolbar ,
.custom #tab1 .ui-widget-header { background: #CEE3F6; border: 0; }
.custom #tab1 .ui-widget-footer { background: #CEE3F6; border: 0; }
/*
.custom #tab1 > .ui-layout-center ,
.custom #tab1 .ui-layout-pane .ui-layout-pane { border: 2px solid #4cbf52; }
.custom #tab1 .ui-widget-content { border: 1px solid #16b81e; }
*/
/* #tab2 */
.custom #tabbuttons .tab2 a { background: #F6F6F6; color: #1C94C4; } /* override UI Theme */
.custom #tabbuttons .tab2 a:hover{background: #FDF5CE;color:#FF0000}
.custom #tabpanels #tab2,
.custom #tab2 .ui-layout-resizer-sliding ,
.custom #tab2 .ui-layout-west , /* sidebar panes too - for when 'sliding' */
.custom #tab2 .ui-layout-east { background: #4794D8; }
.custom #tab2 .ui-layout-resizer-closed { border: 1px solid #4cbf52; }
.custom #tab2 .toolbar ,
.custom #tab2 .ui-widget-header { background: #CEE3F6; border: 0; }
.custom #tab2 .ui-widget-footer { background: #CEE3F6; border: 0; }
/*
.custom #tab2 > .ui-layout-center ,
.custom #tab2 .ui-layout-pane .ui-layout-pane { border: 2px solid #4cbf52; }
.custom #tab2 .ui-widget-content { border: 1px solid #16b81e; }
*/
我嘗試過以下代碼來改變選擇時的顏色......
.custom #tabbuttons .tab1 a:selected{background: #FDF5CE;color:#FF0000}
要么
.custom #tabbuttons .tab1 a:active{background: #FDF5CE;color:#FF0000}
要么
.custom #tabbuttons .tab1 a:clicked{background: #FDF5CE;color:#FF0000}
但沒有人為我工作.....
此外,Body中的標簽編碼如下......
<UL id="tabbuttons" class="hidden">
<LI class="tab1"><A href="#tab1">Track Location</A></LI>
<LI class="tab2"><A href="#tab2">Track Route</A></LI>
</UL>
這里有什么問題......如何改變標簽的顏色......請幫幫我......
我認為您誤解了偽選擇器的使用( http://www.w3.org/TR/CSS2/selector.html#pseudo-elements )。
您將需要應用一個類,使您的<li>
javascript或其他方式選擇。 就像是:
<ul class="navigation">
<li class="selected"><a href="#">First</a></li>
<li><a href="#">First</a></li>
<li><a href="#">First</a></li>
</ul>
.navigation li {background:red;}
.navigation li.selected {background:blue;}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.