Using jQuery to create Vertical Tabs that showcase tab content in an inline-block format

When using jQuery tabs, I recently switched to vertical tabs and noticed that the content is not positioned within the space after the tabs. Instead, it is placed inside a container div with a margin, giving the appearance of being contained within that box. This setup doesn't work well for responsive design.

See example screenshot: https://i.sstatic.net/VebDQ.png

The orange area represents the margin.

I discovered that by adding display: inline-block to each tab, I can ensure the content stays within the space after the tabs. My question is how to add this dynamically instead of manually placing an inline style in every tab's div.

Below is a snippet of the HTML code for my tabs:

<div id="tabs-1" style="display: inline-block">
    <div id="placeholder" class="chart-resize"></div>
    <div id="placeholder2" class="chart-resize"></div>
</div>

<div id="tabs-2" style="display: inline-block">
    <div id="placeholder3" class="chart-resize"></div>
    <div id="placeholder4" class="chart-resize"></div>
</div>

Here is the part of the JavaScript code responsible for creating the vertical tabs:

$("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
$("#tabs li").removeClass("ui-corner-top").addClass( "ui-corner-left" );

All styles are as defined in the default jQueryUI.css file.

Answer №1

Trying to define a class with the attribute display: inline-block and applying it to each tab may not yield the desired results. This is because by doing so, you could inadvertently override the styles of inactive tabs, causing all tab contents to appear as one.

After some experimentation, I discovered a CSS class in the jQuery UI stylesheet that can be modified to change the default display: block attribute to display: inline-block. By making this adjustment, the content is properly contained within each tab's designated area, resulting in a more responsive design.

Below is the code for the class:

.ui-tabs .ui-tabs-panel {
    display: inline-block;
    border-width: 0;
    padding: 1em 1.4em;
    background: 0 0
}

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

Having trouble with the 'on submit' function in PHP using AJAX and jQuery?

After successfully setting up a form to submit shopping cart information to a handler file, I decided to enhance the user experience by integrating ajax and jquery. However, I encountered an issue where the code only works on the first submit. Below is th ...

Gradual appearance animation upon webpage load

I am attempting to create a fading effect on my homepage that is consistent every time it loads. Unfortunately, the current script I have only seems to work sporadically. The code I am currently using sets the fade effect on the html element since applyi ...

Sending a JSON object to an ASP.NET server

I have been attempting to send JSON data to my ASP.NET server on localhost. Initially, I tried posting the code to the master page but encountered a "Error 403: Forbidden" message. Subsequently, I attempted using a web service instead, which led to a myria ...

Dynamic jquery multiple select menu not refreshing properly

Welcome to the new year! I am currently working on creating a multiple select list with the attribute (data-native-menu="false"). The and elements are dynamically generated through a websql query. However, when I execute the code, none of the options are ...

Ways to ensure the synchronous execution of asynchronously invoked functions

I'm currently navigating the world of asynchronous code and trying to grasp its workings. As I construct a Node Express application that interfaces with a database, my aim is for it to interact with a Sqlite database in a development setting. (The pr ...

Switching between links while using Vue Router may cause jQuery to become disabled

I am currently utilizing vue router to facilitate navigation on my website. Within this setup, I have various pages such as a home page and an about us page. The issue I am facing pertains to some jQuery functionality that is implemented in a separate JS f ...

Whenever the page is refreshed, the vertical menu bar with an accordion feature hides the sub

I have designed a vertical accordion menu bar following the example at http://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_accordion_symbol However, I am encountering an issue where clicking on a button to display a submenu causes the page to refr ...

Display a div every 3 seconds with the help of jQuery

I am seeking a solution to display the second div (box2) every 3 seconds. Can anyone help me achieve this using jQuery? <div id="box1" style="background-color:#0000FF"> <h3>This is a heading in a div element</h3> <p>This ...

Troubleshooting issues with Ajax call functionality within a Wordpress website

After doing some research online, I made modifications to functions.php and the front end template in order to trigger an ajax call to retrieve data. However, I am struggling to comprehend how the data is returned from the requested URL. In the functions. ...

Tips for creating a background image that seamlessly adjusts to various computer screen sizes

I am trying to make sure that an image fills the entire browser window, but unfortunately it has fixed width and height dimensions. Is there a way to adjust this so it displays correctly on screens of different sizes? Can CSS be used to stretch the backg ...

Smooth scrolling is not functioning on laptops but is working on mobile phone browsers on a Next.js website

I'm currently experiencing difficulties while trying to implement smooth scrolling in my Next.js application with the help of Tailwind CSS. Strangely enough, the smooth scrolling feature seems to be working flawlessly on mobile browsers, but it just d ...

Navigate to the subsequent frame once the HTML5 video finishes playing

I have created a basic HTML webpage with a fullscreen background video (not set to loop) using the Vide plugin. Everything is working well, but I want the video to pause on the last frame to showcase a logo I have included at the end. This functionality w ...

What is the best way to transfer information from a ReactJS application to an Outlook Template?

I am facing a dilemma with integrating information from an Outlook template into the subject and body of an email. The data I need resides in the FrontEnd, which is developed using React and Javascript. I am uncertain if it's feasible to transfer the ...

Smooth scrolling feature malfunctioning in mobile view

While working on my website, I noticed that the smooth-scroll feature works perfectly on desktop browsers. However, on mobile devices, when I click on a link, it does not scroll to the correct position. It always ends up much lower than expected. Any idea ...

What is the method for retrieving URL parameters in react-router-dom 4 when utilizing the Route render prop rather than the Route component prop?

I am currently utilizing react-router-dom v 4.0.0. Within my top-level <App /> component where my react router is rendered, I have three routes. The first two routes function correctly, however, the third route does not. render() { const pageMa ...

Steps to enable navigation to external pages from a ReactJS app

I am working on a simple ReactJS application: [Demo] [Source] I am trying to implement navigation within the app from external sources without refreshing the web page. This functionality should be similar to using this.props.history.push(...). /public/i ...

Setting a class for a specific date on a jQuery UI calendar using the MultipleDates plugin

I recently encountered an issue with the Multiple Dates picker for jQuery UI date picker. It seems that the developer who created it has not updated it in quite some time, resulting in pre-highlighting dates no longer functioning properly. To address this ...

How to modify CSS variables depending on the parent class: Leveraging the power of Sass and Tailwind CSS

Currently, I am in the process of customizing a Next.js website with Tailwind CSS and working on implementing a theme switching feature utilizing CSS (Sass) variables. There are two primary modes I am focusing on: Default mode: consisting of light and da ...

Determine the precise height of a div element while executing a jQuery animation

I find myself working with some dynamic animation graphs that look pretty neat. However, I am faced with the challenge of accurately displaying the current height of the graph in another div while the animation is taking place, similar to a timer display ...

Converting a JavaScript array into JSON using PHP

After analyzing the text, I was trying to figure out how to convert it into json format using php's json_decode function. Unfortunately, when I used json_decode on this text, it returned a syntax error. $arr = json_decode($str, true); {1: {name: &ap ...