Flex带有活动li的Ul:当li处于活动状态时如何隐藏ul底部

时间:2018-09-24 03:08:39

标签: html css css3 flexbox html-lists

我正在使用一个带有ulli的flex标签。问题是,即使选择了lili底部也不会消失。

这是我的代码:

.scroll-nav-x {
  white-space: nowrap;
  overflow-x: scroll;
  -ms-overflow-style: -ms-autohiding-scrollbar;
}

.scroll-nav-x::-webkit-scrollbar {
  display: none;
}

.scroll-nav-x.scroll-tabs-x {
  display: flex;
  flex-direction: row;
  overflow-y: hidden;
}

.scroll-nav-x.scroll-tabs-x li {
  overflow: visible;
}

ul.tabs {
  margin: 0;
  padding: 0;
  list-style: none;
  height: 53px;
  width: 100%;
  border-bottom: 1px solid grey;
}

ul.tabs li {
  float: left;
  margin: 0;
  cursor: pointer;
  color: blue;
  padding: 5px 30px;
  line-height: 41px;
  overflow: hidden;
  position: relative;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .9px;
  margin: 0 0 -1px;
  border-radius: 3px 3px 0 0;
  display: block;
}

ul.tabs li:hover {
  border: none;
}

ul.tabs li.active {
  display: block;
  color: black;
  background-color: #fff;
  border: 1px solid grey;
  border-bottom-color: transparent;
  cursor: default;
  margin-bottom: 0;
}

.tab-container {
  padding: 30px 0;
}

.tab-container.large {
  padding: 30px;
  border: 1px solid grey;
  border-top: none;
}

.tab-container .col-md-4 {
  padding-bottom: 10px;
}
<ul class="scroll-nav-x scroll-tabs-x tabs clearfix">
  <li class="active" rel="tab1">All</li>
  <li rel="tab2">Others</li>
</ul>

<div class="tab-container large">
  <div id="tab1" class="tab-content" style="display: block;">
    <div class="row">
      Dummy
    </div>
  </div>
</div>

我应该如何设置列表底部,以便在li处于活动状态时,底部边框覆盖ul底部,以在ul和内容区域之间建立无缝连接。谢谢。

1 个答案:

答案 0 :(得分:1)

您可以通过仔细调整CSS来实现此效果。

  1. given data LOC ORG PER MISC 1 LOC/Thai Buddhist temple; 1 0 0 0 #here only LOC is present 2 PER/louis; 0 0 1 0 #here only PER is present 3 ORG/WikiLeaks;LOC/Southern Ocean; 1 1 0 0 #here LOC and ORG is present 4 PER/Eli Wallach;MISC/The Good; 0 0 1 1 #here PER and MISC is present 5 ................................................. 6 0 0 0 0 #here no tag is present 7 ..................................................... ....................................................... ..................................continue up to 2815 rows.... 处添加底边框,其底色与背景颜色相同(在本例中为#fff)
  2. 删除li上的底部边框
  3. 在标签容器的顶部添加边框,然后将其向上移到标签列表下方。

这样,选项卡将与选项卡容器的顶部重叠,并使其看起来像选项卡列表项是选项卡内容的一部分

ul
.scroll-nav-x {
  white-space: nowrap;
  overflow-x: scroll;
  -ms-overflow-style: -ms-autohiding-scrollbar;
}
.scroll-nav-x::-webkit-scrollbar {
  display: none;
}
.scroll-nav-x.scroll-tabs-x {
  display: flex;
  flex-direction: row;
  overflow-y: hidden;
}
.scroll-nav-x.scroll-tabs-x li {
  overflow: visible;
}

ul.tabs {
  margin: 0;
  padding: 0;
  list-style: none;
  height: 53px;
  width: 100%;
  margin-bottom: -1px; /* Modified line */
}

ul.tabs li {
  float: left;
  margin: 0;
  cursor: pointer;
  color: blue;
  padding: 5px 30px;
  line-height: 41px;
  overflow: hidden;
  position: relative;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: .9px;
  margin: 0 0 -1px;
  border-radius: 3px 3px 0 0;
  display: block;
}
ul.tabs li:hover{

  border: none;

}
ul.tabs li.active {
  display: block;
  color: black;
  background-color: #fff;
  border: 1px solid grey;
  border-bottom-color: #fff; /* Modified line */
  cursor: default; 
  margin-bottom: 0;
}
.tab-container {
  padding: 30px 0;
}
.tab-container.large {
  padding: 30px;
  border: 1px solid grey;
  /* Removed line */
}
.tab-container .col-md-4 {
  padding-bottom: 10px;
}