【问题标题】:border on bootstrap tabs content引导选项卡内容的边框
【发布时间】:2015-07-23 14:47:30
【问题描述】:

我想为标签内容添加边框。所选选项卡的底部不应有边框。我发现了这个问题:how to give a border to bootstrap tab contents,但答案对我不起作用?

HTML:

<ul class="nav nav-tabs pull-right">
    <li><a data-toggle="tab" href="#sub_cats_8">תתי קטגוריות</a></li>
    <li class="active"><a data-toggle="tab" href="#category_8">קטגוריה</a></li>
</ul>
<div class="clearfix"></div>
<div class="tab-content" style="height: 100%;">
    <div id="category_8" class="tab-pane fade in active category" style="background-image: url('example.jpg');">
        <h1> קוסמטיקה </h1>
    </div>
    <div id="sub_cats_8" class="tab-pane fade">
        <ul class="sub_categories">
            <li><a href="products.php?act=scat&id=11">איפור</a></li>
        </ul>
    </div>
 </div>

CSS:

body, html {
    direction: rtl;
    height: 100%;
    font-family: Tahoma;
}
.nav-tabs {
    direction: ltr;
}
#logo {
    background-color: #005CB8;
    width: 100%;
    color: white;
    padding: 4% 10%;
    -webkit-box-shadow: 20px 10px 20px #003972;
    -moz-box-shadow: 20px 10px 20px #003972;
    box-shadow: 20px 10px 20px #003972;
    border-bottom-left-radius: 50px;
}
#logo h1, #logo h4 {
    display: inline;
    font-family: head;
}
#logo h1 {
    font-size: 550%;
}
#logo h4 {
    font-size: 220%;
}
.navbar-inverse {
    background-color: #477199;
    font-weight: bold;
}
.nav.navbar-nav.navbar-right li a {
    color: white;
}
.nav.navbar-nav li a {
    color: white;
}
.navbar-inverse .navbar-nav > .active {
    background-color: #003972;
}
.navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
    color: white;
    background: #003972;
}
.navbar-inverse .navbar-nav > li > a:hover, .navbar-inverse .navbar-nav > li > a:focus {
    background-color: #324F6B;
    color: white;
}
.category {
    text-align: center;
    margin-top: 1px;
    background-size: 100% 100%;
    padding: 15% 0;
}
.category h1 {
    color: white;
    font-family: head;
    font-size: 500%;
    text-shadow: 2px -2px black;
}
.category_start {
    margin: 0 auto;
    width: 85%;
}
.sub_categories {
    -webkit-columns: auto 3;
    /* Chrome, Safari, Opera */
    -moz-columns: auto 3;
    /* Firefox */
    columns: auto 3;
    list-style-type: disc;
    margin-top: 5px;
}
.category_start .container {
    margin-top: 10px;
}
.product_image {
    height: 80px;
    width: 80px;
}
.products_sub_list {
    margin: 10px auto 0;
    text-align: center;
    max-width: 80%;
    border-radius: 7px;
}
.products_sub_list td {
    width: 15%;
    max-width: 15%;
    padding: 0 5px;
    border: 3px solid #46617A;
}
.product {
    width: 80%;
    border: 3px solid #46617A;
    margin: 0 auto;
    text-align: center;
    border-radius: 10px;
}
.product_table td {
    border: 2px solid #46617A;
    padding: 13px;
}
.product_table {
    display: inline-table;
    margin-left: 15px;
    margin-bottom: 8px;
}
.product_table td:first-child {
    font-weight: bold;
}
.page {
    width: 85%;
    margin: 0 auto;
    padding: 15px 25px;
    border: 2px solid #46617A;
    border-radius: 10px;
    background-color: #C8D0D7;
}
.register {
    margin: 0 auto;
    width: 80%;
    text-align: center;
}
.register td {
    padding: 5px;
    text-align: right;
}
.register table {
    margin-right: 240px;
}
#register {
    width: 80%;
    position: absolute;
    z-index: 2;
    display: none;
    left: 0;
    right: 0;
    top: 100px;
    margin: 0 auto;
    border: 3px solid #0066FF;
    background-color: #CCE0FF;
    text-align:center;
    border-radius: 10px;
}
#bbg {
    display: none;
    position: absolute;
    z-index: 1;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    background-color: black;
    opacity: 0.8;
    filter: alpha(opacity=80);
}
.tab-content {
    border: 1px solid #ddd;
    padding: 1px;
}

JSFiddle: http://jsfiddle.net/ep2drocb/7/

注意打开的标签有边框,关闭的标签也有双边框。

【问题讨论】:

  • 您能否发布您的代码(如果可能,请发布 JSFiddle),以便我们帮助您解决问题。否则,无法知道为什么该答案(在您发布的 Stackoverflow 链接中)对您不起作用。
  • 好的,我编辑,我粘贴新代码,只是从链接中移动空间

标签: css twitter-bootstrap tabs right-to-left


【解决方案1】:

主要问题是ul 元素上的pull-right

  1. ul 中删除pull-right
  2. 删除 clear-fix 元素,因为它不再需要了
  3. tab-content 类中删除顶部边框
  4. 向右浮动lis
  5. 更正选项卡锚点上的边距

相关 HTML:

<ul class="nav nav-tabs">
    <li class="active"><a data-toggle="tab" href="#category_8">תתי קטגוריות</a></li>
    <li><a data-toggle="tab" href="#sub_cats_8">קטגוריה</a></li>
</ul>
<div class="tab-content">
    <div id="category_8" class="tab-pane fade in active category">
        <h1> קוסמטיקה </h1>
    </div>
    <div id="sub_cats_8" class="tab-pane fade">
        <ul class="sub_categories">
            <li><a href="products.php?act=scat&id=11">איפור</a></li>
        </ul>
    </div>
</div>

相关 CSS:

.tab-content {
    border: 1px solid #ddd;
    border-width: 0 1px 1px; /* Removes the top border */
    padding: 1px;
}
.nav-tabs > li {
    float: right;
}
.nav-tabs > li > a {
    margin-right: 0;
    margin-left: 2px;
}

JSFiddle: http://jsfiddle.net/ep2drocb/9/

这应该会让你走上正轨。

【讨论】:

  • 坦克,很好用,告诉我,你在哪里学的这些东西?因为下次我想自己做,我看getbootstrap.com的文档,那里什么都没有
  • @NatiVaknin 随意将其标记为答案并投赞成票。为了能够解决这个问题,实际上只有一个先决条件。对 CSS 渲染页面的作用有深刻的理解——特别是浮动、位置和显示属性变化。对盒子模型的良好理解也将大有帮助。浏览器中的开发人员控制台是您最好的故障排除工具 - 学习使用它并了解它告诉您的内容。祝你好运。
  • 好的,谢谢,我在哪里将其标记为答案并进行投票?编辑:我没有投票的声誉
  • 买路,你知道引导程序有什么好的文档吗?
  • 你提到的网站getbootstrap.com是官方文档,还不错,不过你也可以直接去github下载源码熟悉一下。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-03
  • 2020-12-16
  • 2015-12-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多