Hide additional tabs on the page when the width of the tabs exceeds the page width

I am currently working on a Google module tab application. I have successfully added the tab control with drag and drop functionality within a specific area. However, I now need to limit the number of tabs displayed on the page. Regardless of the total count of tabs, if they exceed the size of the page, I want the extra tabs to be hidden. How can I implement this feature?

Attached below is a snapshot of my project output where tabs 8 and 9 are appearing on a separate line instead of staying in line with the rest of the tabs. I am looking for solutions to ensure that all tabs remain on the same line. Any suggestions or advice would be greatly appreciated.

To provide more context, here is a visual representation of the issue:

https://i.sstatic.net/hNzcw.jpg

The goal is to keep all tabs on the same line regardless of the window size. If the window is too small to accommodate all tabs, the additional tabs should be hidden. Conversely, if the window is large enough, all tabs should be visible to the user.

The HTML code for the buttons representing each tab is as follows:

<div class="limit">
    <button data-tab="tab-1" class="button current">Car 1</button>
    <button data-tab="tab-2" class="button">Car 2</button>
    <button data-tab="tab-3" class="button">Car 3</button>
    <button data-tab="tab-4" class="button">Car 4</button>
    <button data-tab="tab-5" class="button">Car 5</button>
    <button data-tab="tab-6" class="button">Computer</button>
    <button data-tab="tab-7" class="button">Message</button>
    <button data-tab="tab-8" class="button">Nature</button>
    <button data-tab="tab-9" class="button">Power</button>
</div>

In terms of styling, I have defined CSS properties for both the parent container and button elements:

.parent {
    position: relative;
    margin: 20px;
    width: 800px;
    height: 40px;
}
.button {
    position: relative;
    left: 0;
    display: inline;
    width: 200px;
    height: 75px;
    background-color: lightgray;
    font-size: large;
    border-radius: 4px;
    border: 1px solid #ccc;
    margin: 0 10px 0;
    box-shadow: 0 0 2px #fff inset;
    -webkit-transform: perspective(100px) rotateX(30deg);
    -o-transform: rotateX(30deg);
    -ms-transform: rotateX(30deg);
    -moz-transform: perspective(100px) rotateX(30deg);
}

Answer №1

Here is a solution for you:

Check out the jsfiddle and try dragging the output. It functions exactly as you need it to.

.limit {
 overflow:hidden;
  height:75px;
}
.button {
    position: relative;
    left: 0;
    display: inline;
    width: 200px;
    height: 75px;
    background-color: lightgray;
    font-size: large;
    border-radius: 4px;
    border: 1px solid #ccc;
    margin: 0 10px 0;
    box-shadow: 0 0 2px #fff inset;
    -webkit-transform: perspective(100px) rotateX(30deg);
    -o-transform: rotateX(30deg);
    -ms-transform: rotateX(30deg);
    -moz-transform: perspective(100px) rotateX(30deg);
}
<div class="limit">
    <button data-tab="tab-1" class="button current">Car 1</button>
    <button data-tab="tab-2" class="button">Car 2</button>
    <button data-tab="tab-3" class="button">Car 3</button>
    <button data-tab="tab-4" class="button">Car 4</button>
    <button data-tab="tab-5" class="button">Car 5</button>
    <button data-tab="tab-6" class="button">Computer</button>
    <button data-tab="tab-7" class="button">Message</button>
    <button data-tab="tab-8" class="button">Nature</button>
    <button data-tab="tab-9" class="button">Power</button>
</div>

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

What are the best ways to format an outgoing email using inline CSS?

On my upcoming website, I have set up a single form for guests to subscribe. The issue I am facing is with styling the email that is sent upon submission. I attempted using inline CSS, but it doesn't seem to be working. Instead of transforming the cod ...

Is there a way to enhance the height of Bootstrap combobox items? Can this be achieved?

Is it possible to improve the height of Bootstrap combobox item? How can I achieve that?https://i.sstatic.net/MkGFd.jpg 1 2 3 4 ...

"Utilize Tailwind to effortlessly place a single item at the center

Looking for a way to align a row of items with one item centered in the div and the others positioned on either side while maintaining their original order? Check out this code snippet: <div className="flex mx-auto justify-center items-center" ...

Guide on creating a hand-drawn pencil circle using only CSS!

Is anyone familiar with how to create a hand-drawn pencil circle hover effect using pure CSS, without relying on SVG like the one featured on CodeMyUi? I've seen examples accomplished with SVG, but I'm specifically interested in achieving it usin ...

Delay loading of external JavaScript with data attributes

Exploring options for lazy loading this code snippet: <script async src="https://comments.app/js/widget.js?3" data-comments-app-website="TvibSQx_" data-limit="5" data-color="29B127" data-dislikes="1" dat ...

jQuery - Strip the parent of its class

How do I take off a parent's class? Link to jsfiddle here const panels = document.querySelectorAll('.panel'); const titles = document.querySelectorAll('.section-titles'); panels.forEach(panel => { panel.addEventListener(&apo ...

Difficulty in styling with ag-Grid in SharePoint Framework (SPFX) combined with Angular

I'm currently delving into the world of custom SharePoint Web Parts using SharePoint Framework (SPFX) in combination with Angular Elements. One roadblock I've encountered is that when trying to implement ag-Grid, the style definitions for the gri ...

Exploring new options to deduct time from Kendo UI timepickers without relying on Javascript

My current project involves an Asp.net MVC 4 application that includes a Time entry screen. This screen utilizes various Kendo controls and Razor Html helpers to enhance the user experience, such as: @(Html.Kendo().TimePickerFor(m => m.StartTime).Name( ...

Unable to parse JSON elements using jQuery

Currently, I have an unordered list containing customer names that are retrieved from a JSON file. I am trying to implement a click event using jQuery, but it seems to be having trouble reading it. While the list appears correctly in the HTML source file, ...

What could possibly be causing this element to shift side to side (in IE only) during the CSS animation?

UPDATE: Issue occurring on Internet Explorer 10, Windows 7 When using the transform property to adjust the horizontal position of an element during animation, the vertical value is updated as well. However, despite setting the horizontal value to the same ...

Utilizing Javascript to maintain an ongoing sum within a <span> tag

I'm working on a code snippet to create a running total feature. Essentially, every time a user clicks a button to add the subtotal to the total, I want it to keep accumulating in the running total. Currently, the setup involves a dropdown menu with t ...

Utilize Flexbox's column direction to ensure that all flex items within the same column have uniform height

Having trouble creating a responsive web page. Here are the specifics: Sharing my HTML and CSS code below: - <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA ...

Troubleshooting problem with infinite scrolling in AngularJS with Ionic framework

I recently created a webpage with an infinite scroll page load more script using Ionic AngularJS. However, I encountered an issue where the page restarts from the beginning once it reaches the bottom. Below is the HTML code snippet: <ion-content class ...

Remove the most recent row that was dynamically inserted into an HTML table

Currently, I am in the process of developing an ASP.NET Web Api 2.2 application using .NET Framework 4.5, C#, and jQuery. Within one of my views, I have set up the following table: <table id ="batchTable" class="order-list"> <thead> ...

How can I add a loading page to my HTML/CSS website?

Currently, I am delving into the realm of coding and have encountered an issue while trying to integrate a loading page into my HTML. Despite referencing the code from this source, it appears that the loading page is not functioning as intended. Any assist ...

What is the best way to incorporate new elements into the DOM in order to allow users to share their comments

Can anyone help me with the code below? I have a text box and a comment section, along with a button to add comments. However, I need assistance with adding the posted comment below the comment section. Below is the code snippet: <div id="comments"&g ...

What is the process for extracting HTML tables from files using pandas?

I am a beginner at pandas and I am attempting to extract data from HTML files. How can I convert multiple HTML tables like the ones below: PS4 Game Name | Price GoW | 49.99 FF VII R | 59.99 XBX Game Name | Price Gears 5 | 49.99 For ...

What could be the reason for my MVC 5 ASP.Net application functioning perfectly on my local machine but encountering issues when deployed to Azure

Looking for some help with my first question here. I've recently completed a small ASP.Net project focused on racing drivers and teams, which works well locally but encounters issues when deployed to Azure. The first problem I've encountered is ...

Retrieve the screen width using a JavaScript function and apply it as a percentage

I find myself needing to adjust the size of table elements based on the width of the screen. While I am not well-versed in javascript or html, resolving this issue is crucial. Unfortunately, I did not create the original asp page and have limited ability t ...

Sliding Menu with jQuery

My goal is to create a dynamic menu that reveals sub-menu items by sliding them down and changing the background color upon clicking. I am currently using the HTML code displayed below, with the sub1 and sub2 elements initially hidden using display:none; ...