2016-11-04 184 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>