Implementing a horizontal scroll bar for mobile view using this code tutorial

Can someone provide guidance on how to implement a horizontal scrollbar for mobile view with the following code?

<ul class="nav nav-tabs  nav-justified" id="menutabs" style="width: 100%;">
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_0">
      <i class="material-icons" style="font-size:1rem;">star</i>
    </a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_1">Master</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_2">Transaction</a>
  </li>
  <li class="nav-item">
    <a class="nav-link active" data-toggle="tab" href="#menu_3">Reports</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_4">Analysis</a>
  </li>
  <li class = "nav-item" >
  <a class = "nav-link"
     data - toggle = "tab"
     href = "#menu_6" > Setup</a>
 
   </li>
</ul>

Answer №1

When working with CSS, you have the option to include a scrollbar using the overflow-x property. This can be achieved by setting overflow-x to either:

overflow-x: scroll;

or

overflow-x: auto;

The 'auto' value will only display the scrollbar when necessary, while 'scroll' will always show it.

For instance:

body {
  overflow-x: scroll; /* or use auto*/
}
<li class="nav-item">
            <a class="nav-link" data-toggle="tab" href="#menu_0">
                <i class="material-icons" style="font-size:1rem;">star</i>
            </a>
        </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#menu_1">Master</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#menu_2">Transaction</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link active" data-toggle="tab" href="#menu_3">Reports</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#menu_4">Analysis</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-toggle="tab" href="#menu_6">Setup</a>
                    </li>

    </ul>

Answer №2

To achieve a scrolling effect horizontally, you can use the following CSS property: overflow-x:scroll;

Answer №3

view the image of the scroll here

The flex-wrap property specifies that flexible items should wrap instead of going to the next line, causing horizontal scrolling on mobile devices. The webkit-scrollbar is used to enhance the appearance of the scroll on mobile devices, and this styling only applies to the mobile view.

@media  (max-width: 767px) {
ul#menutabs {
    display: flex !important;
    overflow-x: scroll;
    overflow-y: hidden;
    align-items: center;
    flex-wrap: nowrap;
}
ul#menutabs::-webkit-scrollbar {
    width: 5px;
    height: 2px !important;
}

ul#menutabs::-webkit-scrollbar-thumb {
    background-color: #78909c;
}

ul#menutabs::-webkit-scrollbar-track {
    background-color:#3333334f;
}
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <linK href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="css/style.css">    
</head>
<body>
<ul class="nav nav-tabs  nav-justified" id="menutabs" style="width: 100%;">
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_0">
      <i class="material-icons" style="font-size:1rem;">star</i>
    </a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_1">Master</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_2">Transaction</a>
  </li>
  <li class="nav-item">
    <a class="nav-link active" data-toggle="tab" href="#menu_3">Reports</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_4">Analysis</a>
  </li>
  <li class="nav-item">
    <a class="nav-link" data-toggle="tab" href="#menu_6">Setup</a>
  </li>
</ul>




    <script src="js/jquery-3.6.0.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
</body>
</html>

To enable horizontal scrolling on mobile view, add the following CSS code. To customize the scroll, you can use webkit-scrollbar styles.

@media  (max-width: 767px) {
    ul#menutabs {
            display: flex !important;
            overflow-x: scroll;
            overflow-y: hidden;
            align-items: center;
            flex-wrap: nowrap;
        }
        ul#menutabs::-webkit-scrollbar {
            width: 5px;
            height: 2px !important;
         }
        ul#menutabs::-webkit-scrollbar-thumb {
            background-color: #78909c;
         }
        ul#menutabs::-webkit-scrollbar-track {
            background-color:#3333334f;
         }
}

Answer №4

To incorporate a scroll bar, utilize the overflow-x property. Specify it as:

overflow-x: scroll;

or

overflow-x: auto;

The 'auto' option will automatically add a scrollbar only when necessary, while 'scroll' will always display a scrollbar.

For instance:

body { overflow-x: scroll; /* alternatively, use auto*/ }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Achieving horizontal or vertical alignment of columns in Bootstrap 4 based on viewport size

Here is the layout I am working with - .left { height: 100vh; background-color: #208ea3; } .right { height: 100vh; background-color: #37a862; } <link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="sty ...

Is it possible to create custom animations in react.js using just JavaScript and CSS?

Curious to know if it's achievable in React.js to create animations from the ground up solely using JavaScript and CSS. If so, could anyone guide me to relevant documentation or provide some insight? Much appreciated. ...

How to display a specific HTML section to a select group of individuals using PHP

I have created a section in HTML that I only want to be visible to individuals whose if($Admin >= 1) condition is met based on my database. However, I am uncertain about how to implement this. This is the current state of my HTML code. !-- ADM SECTIO ...

Hiding loading spinner in Ionic 2 upon iframe completion

I need to embed an external webpage in my app using an iframe. I have successfully implemented a loading animation while the iframe is loading, but I am unsure how to hide the animation once the iframe content has loaded. Unfortunately, I am unable to edit ...

Updating an image periodically with React

I'm attempting to create a slideshow that changes images every second. The first image displays, then switches to the alternate display without continuing to switch between pictures. export default class Slideshow extends Component { constructor ...

Building a Table Using HTML and CSS

I'm currently tackling this school assignment and have hit a roadblock with two issues. The HTML Validation error I'm encountering is regarding a table row that is 5 columns wide, exceeding the established count by the first row (4). From line 7 ...

Animate images using mouse vertical movement

Creating websites is just a hobby for me, not something professional. Recently, I came across a beautifully designed website that had some unique features I hadn't seen before, like placing three images in one div (which I researched and learned how t ...

What is the method for activating scrolling in an inner div instead of the browser window?

In the code snippet provided, I am encountering an issue where the browser window scrolls instead of the specified div with overflow-y: scroll when minimizing the browser window. How can I ensure that scrolling occurs within the div itself without making ...

Dynamic template in a Vue.js component, such as an event handler for instance

If I create a component named "test" and add it to my HTML like this: <test :data="foo"></test> How can I make sure that the on-click attribute value changes into the property value 'data'? Vue.component('test', { props: ...

What is the best way to dynamically adjust the width of multiple divisions in Angular?

I am currently working on an angular project to create a sorting visualizer. My goal is to generate a visual representation of an array consisting of random numbers displayed as bars using divisions. Each bar's width will correspond to the value of th ...

Guide to incorporating Bootstrap's bg-variant modifier

I am working with some buttons <button type="button" class="myButton btn btn-primary">foo</button> <button type="button" class="myButton btn btn-secondary">bar</button> ... I want to add transparency to the background colors of th ...

What could be causing my CSS to malfunction when I include two parameters in app.get?

While developing an express app, I encountered an issue where my CSS code stopped working whenever I added an ":ID" parameter to the URL. It seems like a filepath problem because bootstrap is still loading fine, but on the specific page with the ID paramet ...

Utilize orientation detection technology to ascertain the exact placement of an image

On my HTML page, I have a centered header (h1) with a title that displays in portrait mode above an image. When switching to landscape orientation, I want the image to move to the left side of the title. I've experimented with using <br> along ...

Instructions for swapping out the default drop-down icon in my select box with the <i class="icon-xyz-chevron down-rotation"></i> symbol

Is there a way to replace the default drop down arrow with a new one without creating a new class and adding it to the label? <i class="icon-xyz-chevron down-rotation"></i> Any suggestions on achieving this? <label class="col-md-8 col-sm- ...

The use of event.returnValue is outdated and no longer supported. It is recommended to use the standard event.preventDefault() method instead. You may encounter

Hey there :) Currently, I am utilizing JQuery 1.9.1.js to search records using JSON. I am able to retrieve the search list locally, but when attempting to publish it on Windows Server 2008 and IIS 7, I face issues as it throws an error stating "event.ret ...

Using Javascript to create a radio button group

Is there a way to trigger an alert message when all radio buttons are checked as 'no'? I currently am only able to check each radio button individually. //The method I currently know $('#attraction1').change( function(){ if ($(this ...

In CSS, when text within a tab div lacks spaces, it triggers a horizontal scrolling effect

My special css style for the div: .message-body { background: #5181a2; padding: 8px 5px; text-align: justify; } I aim to display this particular text inside the div similar to how 'hello hello' appears on the line above. ...

The iPhone screen is unresponsive, causing the webpage to zoom in to the top left corner repeatedly

I've been wracking my brain trying to solve this issue, searching high and low on this site and others for a solution. I've attempted various configurations with the viewport meta tag, removing the fb-root div, ensuring there is no height=100%, b ...

Modify the appearance of a single component among a collection of 20 instances

I'm looking to dynamically change the background color of my components based on the colors of the images inside them. Each component should have its own unique color, but currently all 20 instances on the page are getting the same color. I've tr ...

Unable to click on element in Firefox browser

Encountering an issue with the following error message: Element is not clickable at point (791, 394). Other element would receive the click: Command duration or timeout: 66 milliseconds Any ideas on what's causing this? Using selenium web driver ve ...