Sliding HTML tabs for easy navigation

Is there a way to display multiple tabs in a limited space by using arrows to toggle between hidden tabs? Or perhaps by dragging the tab strip back and forth as needed?

Imagine having 10 tabs but only room for 5 to be visible:

Tab 1 Tab 2 Tab 3 Tab 4 Tab 5 Tab 6 Tab 7 Tab 8 Tab 9 Tab 10

In this scenario, Tabs 1-5 are visible while Tabs 6-10 are hidden. The goal is to navigate between the visible and hidden tabs by clicking on arrows or dragging the strip. When transitioning, Tabs 1-5 will become hidden.

With each click of the right (or left) arrow, or with each drag, one tab should move accordingly.

Answer №1

Customize Your Slider Tabs with jQuery

Step 1: Adding the Necessary Files

To get started, extract the package into your project directory and include the following files in the head section of your HTML. Remember to ensure jQuery is included before the plugin.

<head>
<link rel="stylesheet" href="styles/jquery.sliderTabs.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/jquery.sliderTabs.min.js"></script>
</head>

Step 2: Structuring Your Tabs

Create a div element that contains an unordered list of tab links followed by corresponding div elements for panels. Ensure the href attribute of the tab links points to the respective panel's ID. Even if you don't plan on using tabs, include this markup for necessary plugin functionality like indicators. Here's a basic example:

<div id="mySliderTabs">
  <ul>
    <li><a href="#canyon">The Grand Canyon</a></li>
    <li><a href="#taj">The Taj Mahal</a></li>
    <li><a href="#bigben">Big Ben</a></li>
  </ul>

  <div id="canyon">
    <h3>The Grand Canyon</h3>
    <!-- Panel content here -->
  </div>
  <div id="taj">
    <h3>The Taj Mahal</h3>
    <!-- Panel content here -->
  </div>
  <div id="bigben">
    <h3>Big Ben</h3>
    <!-- Panel content here -->
  </div>
</div>

Step 3: Activating the Plugin

Select the container div using jQuery and apply the sliderTabs() function to initialize the slider tabs.

var slider = $("div#mySliderTabs").sliderTabs();
... or configure additional options. Refer to the next section for a complete list of available settings.

var slider = $("div#mySliderTabs").sliderTabs({
  autoplay: true,
  mousewheel: false,
  position: "bottom"
});

Learn more about Slider Tabs

Download the Plugin

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

How can I stack a div on top of two columns in Bootstrap?

My goal is to design something like this: I want to have a single-color strip that extends over three columns: https://i.sstatic.net/1XfAu.png What I am aiming for is a layout where the grey line overlaps columns 2 and 3. /* added by editor for demo p ...

What can cause an "Undefined index" error in an ajax POST request and/or PHP script?

When attempting to send an ajax POST request to a PHP file, I encounter an issue where the PHP file returns a notice of "undefined index" and does not receive the value being sent. Despite researching extensively to find a solution, I have been unable to r ...

Creating a navbar that sticks to the top of the page

I've been working on some code to create a sticky navbar that remains fixed as I scroll down, but unfortunately, it's not working. I suspect the issue might lie in the CSS, as the HTML and javascript seem fine. Interestingly, this same code has w ...

Disappearing Jquery mobile panel following a postback

I am currently facing an issue with a usercontrol (asp.net) embedded inside a jquerymobile panel. This specific usercontrol is a standard contact form with a submit button, along with back-end error validation. Following the postback, I aim to display thes ...

Utilizing the .data() method for establishing a variable

I am facing an issue while trying to set a variable in a form using .data(). The problem is that I cannot see any output for the variable "fee" - it just appears blank. What I am trying to achieve is for the user to select a Type, enter a footage, and then ...

Ensure Safari sends the Origin header in jQuery GET requests

When I send a request from https://app.example.com, the following code is executed: $.get('https://api.example.com', { foo: 'bar' }) .success(getSuccess) .error(getError); This script runs smoothly on Chrome and Firefox, however, ...

Problem faced with Modal in Bootstrap 5 and Blazor

I have been working on a Blazor project that utilizes Bootstrap for modal handling. Specifically, I am trying to leverage the data-bs-backdrop and data-bs-keyboard attributes in my ModalAlert.razor component to manage how the backdrop and keyboard behave w ...

Setting the background image of a div in my Angular application by utilizing the value returned from an API call

I'm currently working on a movie search application where I need to set an image as the background of a div. The URL for this background image is fetched from an API call. Here is what I have tried so far: <div *ngFor="let movie of movies.results ...

Utilize Sass @extend to incorporate imported CSS files in the build process

In my development setup, I have a global CSS file that houses all of the generic CSS styles. My goal is to extend the classes from this global CSS file in any of my SCSS files. However, when I attempt to do so, I encounter an error stating that the .xyz c ...

Discover a method to prohibit the use of numbers

Can someone provide me with a Regex pattern to restrict the input in the Name field to only include a mix of text and numbers? I do not want names that consist solely of numbers like 12345678, 3241238215, or 4323438. Rather, it should contain both text and ...

Discover the steps to incorporate a glowing effect into your custom progress bar using JavaFX

After successfully creating a custom progress Bar in JavaFX, my next step is to incorporate a glow effect into the progressBar. To achieve this, I have constructed an ellipse with a Gaussian blur effect and integrated the centerX of the ellipse into a tim ...

Applying the transform:scale property to the parent element causes the child element's dropdown menu to appear beneath a different row

When attempting to scale my row on hover, I encounter an issue with my dropdown menu. If the dropdown menu is open, it gets hidden under the next row. How can I ensure that it stays on top? I have tried using z-index, but it doesn't seem to help. The ...

My ng-view html is unexpectedly displaying as plain string. What steps should I take to resolve this issue?

Why is my ng-view HTML displaying as plain text? How can I resolve this issue? I have encountered an error, here is the screenshot for reference: Unfortunately, I am unable to upload images at the moment. ...

Need assistance with CSS layout: How to extend a div to the bottom of the page

I am currently working on a design layout that includes a 'header' section with a logo and links, as well as a content area that should extend to the bottom of the page. However, I am facing some challenges in achieving this. Initially, I enclos ...

"Revamp the appearance of the div element upon clicking elsewhere on the

function replace( hide, show ) { document.getElementById(hide).style.display="none"; document.getElementById(show).style.display="flex"; } @import url('https://fonts.googleapis.com/css2?family=Allerta+Stenci ...

Fetching JSON data from an external API using JavaScript

What is the most efficient way to load a JSON feed from an external source using JavaScript? I am familiar with PHP's file_get_contents and cURL methods, but is there a similar function or approach in JavaScript? ...

Why aren't jQuery events triggering following an AJAX request?

I have created a website that utilizes fading effects to transition between sections while loading new content. One of the features includes enlarging an image upon clicking, which is achieved through a jQuery event trigger. The issue I am facing is that ...

The gaps separating rows

I'm struggling with getting my divs to look like a table, especially when it comes to highlighting a selected row. I've tried adjusting padding and margins without success. Does anyone have any suggestions on how I can achieve this effect? .ta ...

I'm having difficulties with separators in CSS when I attempt to insert one

Hey there, I've encountered an issue with my separator: #menu li:not(:first-child):before { content: " | "; } Despite this code working, the first li item isn't being separated like the others. This is the current output I'm getting: t ...

Having trouble parsing PHP JSON encoded data in JavaScript

When I make an AJAX call to a PHP script that returns a JSON encoded object, I encounter some issues. $.post("php/getCamera.php", { cam_id: identifier }, function(data){ console.log(data); //var camera = JSON.parse( ...