【问题标题】:How to Scroll nav-pills (Bootstrap 3) horizontally?如何水平滚动导航药丸(Bootstrap 3)?
【发布时间】:2020-04-03 09:42:56
【问题描述】:

我正在将新的 Bootstrap 3 用于导航药丸,我想让所有药丸都保持在一条可以滚动的水平线上(即使在每个药丸的标题中也不换行)。即使是 3 粒药丸,因为 我正在尝试将其用于小屏幕。比如智能手机。

我尝试了一些解决方案:
Scroll Bootstrap 4 nav-tabs horizontally
Bootstrap horizontal scrollable tab bar

但我无法弥补。您可以在我的网站页面中看到我的问题:

https://karneta.com/downloads/how-to-create-an-audience-persona/

请帮忙解决这个问题。

HTML

    <div class="singleinfos">
        <div class="row container-fluid ">
                <div class="singleinfostabs">
                    <ul class="nav nav-pills">
                        <li class="active"><a data-toggle="pill" class="moretab" href="#cootab11">سرفصل های دوره</a></li>
                        <li><a data-toggle="pill" class="moretab" href="#cootab12">نمونه های دوره</a></li>
                        <li><a data-toggle="pill" class="moretab" href="#cootab13">توضیحات بیشتر</a></li>
                    </ul>
                </div>
                <div class="tab-content">
                    <div id="cootab11" class="tab-pane fade in active sarfasldowre">

                        Text One

                    </div>

                    <div id="cootab12" class="tab-pane fade">

                        Text Two

                    </div>

                    <div id="cootab13" class="tab-pane fade">

                        Text Three

                    </div>
                </div>
        </div>
    </div>

</div>

CSS

.singledowre {
    background-color: transparent;
    min-height: 100%;
    padding: 40px 14px;
    background-image: url(img/shapes.png) !important;
    background-size: 17%;
}
.singledowrediv {
    display: table;
    margin: 0 auto;
    max-width: 950px;
}
.singleinfos {
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin: 15px 0;
}
.container-fluid {
    padding-right: 0 !important;
    padding-left: 0 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
}
.singleinfos .singleinfostabs {
    margin-bottom: 20px;
}
.singleinfos .singleinfostabs > ul {
    display: flex;
    width: 100%;
    margin-bottom: 14px;
}
.singleinfos .singleinfostabs > ul > li {
    background: white;
    background: #869daf;
    border-radius: 3px;
    padding: 12px 0;
    width: 100%;
    margin-left: 10px;
    margin-right: 0;
    margin-bottom: 20px;
}
.singleinfos .singleinfostabs .nav-pills > li > a {
    font-size: 13px;
    border-radius: 4px;
    padding: 4px 10px;
    text-align: center;
    background: transparent;
    color: white !important;
}

【问题讨论】:

标签: html css twitter-bootstrap-3 tabs nav-pills


【解决方案1】:

用你的 css 替换下面的 css。然后检查一下。

.singledowre {
    background-color: transparent;
    min-height: 100%;
    padding: 40px 14px;
    background-image: url(img/shapes.png) !important;
    background-size: 17%;
}
.singledowrediv {
    display: table;
    margin: 0 auto;
    max-width: 950px;
}
.singleinfos {
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin: 15px 0;
}
.container-fluid {
    padding-right: 0 !important;
    padding-left: 0 !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
}
.singleinfos .singleinfostabs {
    margin-bottom: 20px;
	width: 100%;
}
.singleinfos .singleinfostabs > ul {
     overflow-x: auto;
   overflow-y:hidden;
   flex-wrap: nowrap;
    margin-bottom: 14px;
}
.singleinfos .singleinfostabs > ul > li {
    background: white;
    background: #869daf;
    border-radius: 3px;
    padding: 12px 0;

    margin-left: 10px;
    margin-right: 0;
    margin-bottom: 20px;
}
.singleinfos .singleinfostabs .nav-pills > li > a {
    font-size: 13px;
    border-radius: 4px;
    padding: 4px 10px;
    text-align: center;
    background: transparent;
    color: white !important;
	white-space: nowrap !important;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css">

<div class="singleinfos">
  <div class="row container-fluid ">
    <div class="singleinfostabs">
      <ul class="nav nav-pills">
        <li class="active"><a data-toggle="pill" class="moretab" href="#cootab11">سرفصل های دوره</a></li>
        <li><a data-toggle="pill" class="moretab" href="#cootab12">نمونه های دوره</a></li>
        <li><a data-toggle="pill" class="moretab" href="#cootab13">توضیحات بیشتر</a></li>
        <li><a data-toggle="pill" class="moretab" href="#cootab13">توضیحات بیشتر</a></li>
        <li><a data-toggle="pill" class="moretab" href="#cootab13">توضیحات بیشتر</a></li>
        <li><a data-toggle="pill" class="moretab" href="#cootab13">توضیحات بیشتر</a></li>
        <li><a data-toggle="pill" class="moretab" href="#cootab13">توضیحات بیشتر</a></li>
      </ul>
    </div>
    <div class="tab-content">
      <div id="cootab11" class="tab-pane fade in active sarfasldowre"> Text One </div>
      <div id="cootab12" class="tab-pane fade"> Text Two </div>
      <div id="cootab13" class="tab-pane fade"> Text Three </div>
    </div>
  </div>
</div>

【讨论】:

  • 非常感谢我的朋友帮助我。我测试了你的解决方案,但我对我不起作用。您可以在以下链接中看到我的页面。我的药片在页面底部。可以看到三颗药丸:karneta.com/downloads/how-to-create-an-audience-persona
  • 我已经检查了你的页面。仍然存在旧的CSS。确保你已经更换了新的 CSS。此外,如果您使用任何缓存系统,请删除缓存。希望,这有帮助。
  • 我的朋友,现在检查页面。我添加了新代码,但没有滚动。
  • 请注意,对于
  • 这里是 bootstrap 4 的解决方案。但是,在这里,我已经在您的站点中实现了。 Bootstrap 3 已在您的站点中使用。并且您正在询问有问题的引导程序 4。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多