首页 > 解决方案 > CSS中带有以下线条的自定义选项卡

问题描述

我正在设计一个应用程序,其中我希望有如下标签

在此处输入图像描述

但目前我看到如下内容(由框覆盖)

在此处输入图像描述

我在网上搜索了类似的设计,但没有找到任何东西。你能帮助实现同样的目标吗?

更新

我可以得到border-bottom: 2px solid blue;下面的蓝线,但突出显示的框仍然出现,如下所示。我也想避免这种情况。

在此处输入图像描述

标签: htmlcsstabscustomization

解决方案


.tabs {
  position: relative;   
  min-height: 200px; /* This part sucks */
  clear: both;
  margin: 45px 0 25px;
  background: white;
  color: #41C0ED;
  font-weight:bold;
  padding: 5px;
}
.tab {
  float: left;
   
}
.tab label {
  background: #fff; 
  padding: 10px; 
  border-bottom: 1px solid #ccc; 
  margin-left: -1px; 
  position: relative;
  left: 1px; 
  top: -29px;
 
}
.tab [type=radio] {
  display: none;   
}
.content {
  position: absolute;
  top: -1px;
  left: 0;
  background: white;
  right: 0;
  bottom: 0;
  padding: 20px;
  border-top: 1px solid #ccc;
  -webkit-transition: opacity .6s linear;
  opacity: 0;
}
[type=radio]:checked ~ label {
  border-bottom: 2px solid #308AC2;
  z-index: 2;
  padding-bottom: 4px;
}
[type=radio]:checked ~ label ~ .content {
  z-index: 1;
  opacity: 1;
}
<div class="tabs">
    
   <div class="tab">
       <input type="radio" id="tab-1" name="tab-group-1" checked>
       <label for="tab-1">Tab One</label>
       
       <div class="content">
           
       </div> 
   </div>
    
   <div class="tab">
       <input type="radio" id="tab-2" name="tab-group-1">
       <label for="tab-2">Tab Two</label>
       
       <div class="content">
           
       </div> 
   </div>
    
    <div class="tab">
       <input type="radio" id="tab-3" name="tab-group-1">
       <label for="tab-3">Tab Three</label>
     
       <div class="content">
          
       </div> 
   </div>
    
</div>


推荐阅读