Interact with scrollable tabs on your mobile device with ease

I'm currently working on creating touch scrollable tabs using Bootstrap 4, specifically for mobile view. I attempted to modify a Bootstrap 3 code snippet found at to work with Bootstrap version 4.

You can find the Codepen demo here: https://codepen.io/Bizboss/pen/zYGEOjO

Here's the HTML structure:

<div class="container">  
      <div class="row">
        <div class="col">
            <!-- Nav tabs -->
            <div class="card">
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Home</a></li>
                    <li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Profile</a></li>
                    <li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Messages</a></li>
                    <li role="presentation"><a href="#settings" aria-controls="settings" role="tab" data-toggle="tab">Settings</a></li>
                    <li role="presentation"><a href="#about" aria-controls="about" role="tab" data-toggle="tab">About</a></li>
                    <li role="presentation"><a href="#contact" aria-controls="contact" role="tab" data-toggle="tab">Contacts</a></li>
                </ul>
                <div class="tab-content">
                    <!-- Tab panes content goes here -->
                </div>
            </div>
        </div>

For the CSS styling, you can refer to the following snippet:

/* Custom CSS styles go here */
body {
  background: #EDECEC;
}

/* More custom styles */

@keyframes example {
  /* Your keyframe animation goes here */
}

If you have any suggestions or solutions on how to make this work properly, please feel free to share them!

Answer №1

The version of Bootstrap you are using (4.*.*) is not the same as the one in the tutorial (3.*.*) you are following.

You have two options: either switch to version 3.*, or add the following style to your CSS:

.nav{
    flex-wrap: inherit; 
}

Explanation: The reason for this is that in version 4, the nav style is set as flex-wrap: wrap.

CodePen example: https://codepen.io/hellooutlook/pen/XWbeWjd

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

The scrollbar remains unresponsive and fixed until the screen size is adjusted

Need some assistance with a website project for a client. The scrollbars on each page are not loading or changing height until the window is resized. I have a jQuery scrollbar in place, but disabling it does not solve the issue as the normal scrollbar beha ...

What is the most effective way to showcase a variety of random styles for various text elements within a single webpage?

Currently brainstorming some new concepts and contemplating a unique site layout idea that involves randomizing the styles of specific elements on a webpage. For instance, envision having 10 paragraphs on one page where each paragraph is presented in a dif ...

animation glitches in safari and chrome when using jquery

Hey there! I'm currently working on a form with multiple steps, where I animate the step number for each level of registration. The animation functions perfectly in Firefox, but unfortunately, it's not supported in Chrome and Safari due to an iss ...

"Javascript encountered an unrecognizable expression when trying to parse a single

Whenever this event occurs, I'm encountering a console error that states "unrecognized expression: .". Everything seems to be working fine so I'm not entirely sure what the issue is other than possibly a syntax error. Any suggestions or ideas on ...

IE having issues with selecting all options button in jQuery, but it is functioning correctly in Firefox

In one part of my cgi code, I create the following: my $PARAMETER_HTML .= "<select name='parameters' id='parameters' size='10' multiple='multiple'>"; foreach my $values (sort @PARA_VALUES) { $PARAMETER_HTM ...

Checking with JQuery if the alt tag of an image is contained in a variable array, and then applying a class accordingly

My webpage consists of an html grid displaying various images. I am looking to utilize JQuery to dynamically add HTML to all images that contain alt tags matching items from a specified list or array. While there are numerous tutorials available on using ...

The Bootstrap toast feature does not seem to be functioning properly within the context of

I am facing an issue with my datatable table where the Bootstrap toast component is not working correctly when placed above the table due to the backdrop-filter property. The toast functions normally when placed within any other element except for the tab ...

The for loop is not pausing to wait for the callback to complete within the loop

My objective is to display multiple .stl files in various divs on a webpage and retrieve model information for each model (such as volume, area, xyz coordinates, etc.). To accomplish this, I am utilizing , which is built on three.js The HTML code snippet: ...

Encountering issues with CSS Modules in Next.JS app while using app/about/layout.tsx

Currently, I am delving into the world of Next.js and encountering some challenges with locally scoped CSS modules. In my project, I have an about directory which contains a layout component. Strangely, the styles applied to the layout component are not b ...

JQuery is capable of hiding a div using the .hide() method but is unable to reveal it using the

I am currently working on a basic webpage that includes a question and a set of radio buttons. Depending on the option selected by the user, the question will be hidden and either a correct or incorrect message will be displayed, both of which are initiall ...

Is there a way to reduce the spacing between these child containers when they wrap?

I'm looking to reduce the space between my child divs when they wrap It seems like the issue lies within the media query * { margin: 0; padding: 0; box-sizing: border-box; } html { font-size: 10px; width: 100%; } html, bo ...

What is the best way to disable dragging for specific div elements in Angular 2 using Dragula?

I have successfully incorporated the ng2-dragula into my project, but I am facing challenges in making certain divs non draggable. I attempted to use some css and set draggable="false" for the div in HTML, but unfortunately, nothing seems to work. It appe ...

The best method for quickly loading a webpage that is over 20MB in size

My website is a single-page calendar featuring a full year's worth of images. With 344 requests and a total load size of 20MB, the page consists of a simple PHP script without a database. The requests include a CSS file (15KB), 4 JS files (20KB), two ...

Align audio and video elements in HTML5 using JavaScript

I am facing a situation where I have two files - one is a video file without volume and the other is an audio file. I am trying to play both of these files using <audio> and <video> tags. My goal is to make sure that both files are ready to pla ...

What is the best way to style the header of a table when scrolling in CSS?

Currently, I am facing an issue with applying the top CSS property to the thead element of a table while scrolling. I have attempted various methods but have been unsuccessful in achieving the desired outcome. Initially, I used the scroll event, however, ...

Column spacing and size manipulation with Bootstrap 4

I'm currently facing an issue with aligning elements and spacing them correctly in my project. How can I resolve this using only the col class and Bootstrap 4, without resorting to CSS? I have attempted various margin spacing options like ml-md-4 and ...

Implement a smooth transition effect when changing the image source

I am currently working on enhancing a Squarespace website by adding a new image fade-in/fade-out effect when the mouse hovers over one of three buttons. The challenge I'm facing is that the main static image is embedded as an img element in the HTML r ...

Mirror the image horizontally prior to saving

I'm working on a camera web app that has filters similar to Snapchat. I'm currently facing an issue where the image is mirrored because I'm using the front camera. Is there a way to flip the image before downloading it? Thank you for your re ...

JavaScript and HTML code for clipboard functionality without the need for Flash

My challenge lies in creating a grid with numerous columns and data. The user has expressed the desire for a copy to clipboard button that will allow them to easily copy the data. Can anyone suggest ways to implement Copy to Clipboard functionality withou ...

What is the best way to use AJAX to download an image and set it as the background of a div element?

My approach involves downloading a .jpg or .png file that contains all the interface images (such as arrows, buttons, and borders) used on the site. To utilize an image, I simply create a div: <div id="img_left_arrow"></div> In the CSS, I spe ...