【问题标题】:Custom Tabs with Line below in CSSCSS中带有以下线条的自定义选项卡
【发布时间】:2019-06-12 06:53:37
【问题描述】:

我正在设计一个应用程序,其中我想要如下所示的选项卡

但目前我看到的是下面的内容(被框覆盖)

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

更新

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

【问题讨论】:

  • 你的代码在哪里?
  • 你可以试试border-bottom
  • @xmaster ,它是一个应用程序提供的选项卡。使用 UI,我可以创建一个没有任何代码的选项卡。但我也可以使用自定义 CSS 进行自定义。
  • 那么我将包含类似 border-bottom: 2px solid blue;:active 的内容
  • @JoohongTan , @xmaster 感谢border-bottom 我可以得到如下图所示的行。但仍然出现灰色突出显示的框。如何避免这种情况。已编辑问题

标签: html css tabs customization


【解决方案1】:

.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>

【讨论】:

  • 如果我是你,我会将 min-height: 200px 更改为 vh(使用视口)
【解决方案2】:

您可以使用: background-color: transparent !important;

【讨论】:

  • 一般来说,你应该尽量避免使用!important
  • @xmaster 好的,但为什么不回答自己呢?
  • 你试试看有什么问题吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-17
  • 2019-08-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多