2016-11-04 227 views
-2

目前我正在使用一個簡單的標籤菜單,並希望在標籤處於活動狀態時顯示向下箭頭。這是我正在使用的當前代碼。我已經嘗試了jQuery中的一些東西,但沒有運氣。 CSS似乎是實現這一目標的最佳方式。我對麼?你會如何做到這一點?向下箭頭添加標籤菜單

順便說一句,檢查完整頁面視圖中的代碼,以獲得更好的樣式。

.tab_menu { 
 
    margin: 40px 30px 0 30px; 
 
} 
 
ul.tab { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    overflow: hidden; 
 
    border: 1px solid #ccc; 
 
    background-color: rgba(68, 170, 255, 0.1); 
 
} 
 
/* Float the list items side by side */ 
 

 
ul.tab li { 
 
    border-left: 1px solid #ccc; 
 
    float: left; 
 
    margin-bottom: 0; 
 
    margin-left: 0; 
 
} 
 
/* Style the links inside the list items */ 
 

 
ul.tab li a { 
 
    display: inline-block; 
 
    color: black; 
 
    /* text-align: center; */ 
 
    padding: 14px 9px 14px 9px; 
 
    text-decoration: none; 
 
    transition: 0.3s; 
 
    font-size: 17px; 
 
    margin: 0; 
 
    width: 150px; 
 
    height: 35px; 
 
    text-align: center; 
 
} 
 
/* Change background color of links on hover */ 
 

 
ul.tab li a:hover { 
 
    background-color: rgba(68, 170, 255, 0.5); 
 
} 
 
/* Create an active/current tablink class */ 
 

 
ul.tab li a:focus, 
 
.active { 
 
    background-color: rgba(68, 170, 255, 0.9); 
 
} 
 
/* Style the tab content */ 
 

 
.tabcontent { 
 
    display: none; 
 
    padding: 25px 12px; 
 
    border: 1px solid #ccc; 
 
    border-top: none; 
 
} 
 
.tab_menu a { 
 
    text-align: center; 
 
} 
 
.triangle-bottom { 
 
    border-top: solid 20px #54b1ff; 
 
    border-left: solid 25px transparent; 
 
    border-right: solid 25px transparent; 
 
    width: 0; 
 
    height: 0; 
 
    position: absolute; 
 
    margin-left: 168px;
<div class="tab_menu"> 
 
    <ul class="tab"> 
 
    <li><a href="javascript:void(0)" class="active tablinks" onclick="openContent(event, 'coverage');" id="defaultOpen">Our Coverage</a> 
 
     <div class="triangle-bottom"></div> 
 
    </li> 
 
    <li><a href="javascript:void(0)" class="tablinks" onclick="openContent(event, 'claims')">Common Claims</a> 
 
    </li> 
 
    <li><a href="javascript:void(0)" class="tablinks" onclick="openContent(event, 'bwc')">Buy With Confidence</a> 
 
    </li> 
 
    <li><a href="javascript:void(0)" class="tablinks" onclick="openContent(event, 'faq')">Frequently Asked Questions</a> 
 
    </li> 
 
    </ul> 
 
</div>

+0

?它應該如何看待?你有它的圖標? –

+0

我已更新代碼以顯示選項卡下方的箭頭。這不完全如此,但它至少顯示了箭頭。 – trav

+0

但你沒有提到箭頭的確切位置 –

回答

1

從你提供的代碼,只需調整左旁哪裏應該向下箭頭顯示的作業

.triangle-bottom { 
    margin-left: 119px; 
} 

.tab_menu { 
 
    margin: 40px 30px 0 30px; 
 
} 
 
ul.tab { 
 
    list-style-type: none; 
 
    margin: 0; 
 
    padding: 0; 
 
    overflow: hidden; 
 
    border: 1px solid #ccc; 
 
    background-color: rgba(68, 170, 255, 0.1); 
 
} 
 
/* Float the list items side by side */ 
 

 
ul.tab li { 
 
    border-left: 1px solid #ccc; 
 
    float: left; 
 
    margin-bottom: 0; 
 
    margin-left: 0; 
 
} 
 
/* Style the links inside the list items */ 
 

 
ul.tab li a { 
 
    display: inline-block; 
 
    color: black; 
 
    /* text-align: center; */ 
 
    padding: 14px 9px 14px 9px; 
 
    text-decoration: none; 
 
    transition: 0.3s; 
 
    font-size: 17px; 
 
    margin: 0; 
 
    width: 150px; 
 
    height: 35px; 
 
    text-align: center; 
 
} 
 
/* Change background color of links on hover */ 
 

 
ul.tab li a:hover { 
 
    background-color: rgba(68, 170, 255, 0.5); 
 
} 
 
/* Create an active/current tablink class */ 
 

 
ul.tab li a:focus, 
 
.active { 
 
    background-color: rgba(68, 170, 255, 0.9); 
 
} 
 
/* Style the tab content */ 
 

 
.tabcontent { 
 
    display: none; 
 
    padding: 25px 12px; 
 
    border: 1px solid #ccc; 
 
    border-top: none; 
 
} 
 
.tab_menu a { 
 
    text-align: center; 
 
} 
 
.triangle-bottom { 
 
    border-top: solid 20px #54b1ff; 
 
    border-left: solid 25px transparent; 
 
    border-right: solid 25px transparent; 
 
    width: 0; 
 
    height: 0; 
 
    position: absolute; 
 
    margin-left: 119px; 
 
    }
<div class="tab_menu"> 
 
    <ul class="tab"> 
 
    <li><a href="javascript:void(0)" class="active tablinks" onclick="openContent(event, 'coverage');" id="defaultOpen">Our Coverage</a> 
 
     <div class="triangle-bottom"></div> 
 
    </li> 
 
    <li><a href="javascript:void(0)" class="tablinks" onclick="openContent(event, 'claims')">Common Claims</a> 
 
    </li> 
 
    <li><a href="javascript:void(0)" class="tablinks" onclick="openContent(event, 'bwc')">Buy With Confidence</a> 
 
    </li> 
 
    <li><a href="javascript:void(0)" class="tablinks" onclick="openContent(event, 'faq')">Frequently Asked Questions</a> 
 
    </li> 
 
    </ul> 
 
</div>