How to Scroll nav-pills (Bootstrap 3) horizontally?
Asked Answered
P

1

0

I am using the new Bootstrap 3 for nav-pills and I want to make all the pills stay in one horizontal line that can be scrolled (no wrap, even in title of every pill). even for 3 pills because I am trying that for small screen. like smartphones.

I tried some solutions:
Scroll Bootstrap 4 nav-tabs horizontally
Bootstrap horizontal scrollable tab bar

but I could not make it up. you can see my problem in my website page:

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

Please help out to solve that.

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;
}
Photosensitive answered 3/4, 2020 at 9:42 Comment(2)
The external site doesn't really show the issue. Are you looking for something like this? https://mcmap.net/q/1169667/-responsive-horizontal-scrolling-menu OR #53499096Spue
@Zim thank a lot my friend for helping me. for my question, I need the scrolling horizontally for small screens (smartphones) < 320px. if you use inspect on chrome for < 320px, you can see that pills can not be scrolled and every pill is not in one line (it is wraped)Photosensitive
R
0

Replace following css with your css. & then check it.

.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>
Runabout answered 3/4, 2020 at 11:49 Comment(6)
thanks a lot my friend for helping me. I tested your solution but i doesn`t not work to me. you can see my page in the following link. my pills are in the bottom of page. you can see three pills: karneta.com/downloads/how-to-create-an-audience-personaPhotosensitive
I have check your page. there are still old css present. make sure, you have replace new css. also, remove cache if you are using any cache system. Hope, this help.Runabout
my friend, now check the page. I add new codes but with no scrolling.Photosensitive
notice that I need the scrolling horizontally for small screens (smartphones) < 320px. if you use inspect on chrome for < 320px, you can see that pills can not be scrolled and every pill is not in one line (it is wraped). I need just 3 pillsPhotosensitive
Here, this solution for bootstrap 4. but, Here, I have realized in your site. Bootstrap 3 use has been in your site. and You are asking bootstrap 4 in question.Runabout
Oh, excuse me really. It was a mistake. would you help me for Bootstrap 3?Photosensitive

© 2022 - 2024 — McMap. All rights reserved.