Tab panels are shown by Bootstrap 5 tabs

I am using Bootstrap 5 to design a layout that changes based on the width of the screen. When the screen width is greater than or equal to 992 pixels, a table is displayed in the sidebar and some text is shown in the main content area. However, if the screen is resized to less than 992 pixels, the sidebar disappears, and both the table and text are displayed as tabbed panels in the main content area. Here is the code for this layout:

 <main class="container">
        <div class="row">
            <aside class="d-none d-lg-block col-lg-4">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th colspan="2">My Car</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>Year</td>
                            <td>2023</td>
                        </tr>
                        <tr>
                            <td>Make</td>
                            <td>Honda</td>
                        </tr>
                        <tr>
                            <td>Model</td>
                            <td>Civic</td>
                        </tr>
                        
                    </tbody>
                &

When the screen is less than 992px wide, the text only displays in the main content area if that tab was selected. This issue seems to be related to the ".active" class that Bootstrap uses to add/remove tabs when they are clicked. I am unsure how to resolve this problem.

Check out the CodePen link for reference.

Answer №1

The Bootstrap tabs are initially hidden and only displayed when selected.

.tab-content>.tab-pane {
    display: none;
}


To work around this, you can add the d-lg-block class to the #text div.

<div class="d-lg-block tab-pane fade show tab-container" id="text">


However, if a user transitions between tabs in a narrow viewport and then expands the viewport, the issue may recur as the JS removes the show class.

.fade:not(.show) {
    opacity: 0;
}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vel massa laoreet, tristique est eget, pulvinar lacus. Nam nec diam at diam elementum porttitor ac ac sapien. Quisque ut consectetur magna. Suspendisse vestibulum magna mollis, elementum justo at, aliquet lorem. Etiam auctor nisi vitae efficitur sagittis. Morbi dui sem, consectetur vel fermentum sit amet, sollicitudin eget lectus. Mauris malesuada faucibus diam, in condimentum risus lacinia finibus. Aliquam porta ornare lacus, a blandit dolor interdum vel.

My Car
Year 2023
Make Honda
Model Civic

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vel massa laoreet, tristique est eget, pulvinar lacus. Nam nec diam at diam elementum porttitor ac ac sapien. Quisque ut consectetur magna. Suspendisse vestibulum magna mollis, elementum justo at, aliquet lorem. Etiam auctor nisi vitae efficitur sagittis. Morbi dui sem, consectetur vel fermentum sit amet, sollicitudin eget lectus. Mauris malesuada faucibus diam, in condimentum risus lacinia finibus. Aliquam porta ornare lacus, a blandit dolor interdum vel.


If duplicating content is not ideal but redesigning isn't an option, consider duplicating both the table and text for consistency.

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

Tips for changing the color of shapes when hovering over an image state

I have arranged three images in a column and applied column-count: 3; along with setting border-width for those images. Now I am curious about how to create the hover state for these images. Here is the HTML code snippet: <div class="wrap"> < ...

Sending information from a parent component to a nested child component in Vue.js

Currently, I am facing a challenge in passing data from a parent component all the way down to a child of the child component. I have tried using props to achieve this as discussed in this helpful thread Vue JS Pass Data From Parent To Child Of Child Of Ch ...

Obtain the Week Input's Value

Is there a way to store the value of a week input in a variable and then display it in a span? I attempted the following code: <input type="week" name="week" id="week-selector"> <span id="kalenderwoche"> ...

Simulating a mobile device screen size using an embedded iframe

Imagine this scenario: What if instead of adjusting the browser window size to showcase a responsive web design, we could load the site into an IFRAME with the dimensions of a mobile screen. Could this concept actually work? Picture having an IFRAME like ...

Troubleshooting problem with CSS layout when adjusting the height of a section

I recently delved into creating a simple website using HTML5 and have successfully set up the site structure. Everything has been smooth sailing so far. However, I've encountered a section of the site that seems to have a mind of its own. When I ass ...

Leveraging JQuery animation to manipulate the spinning of HTML jackpot

I have been using the following code to simulate a spinning wheel for users. It is functional, but I am facing an issue where the rotation stops abruptly at a specific circle before applying the style for the winning circle. My query is: Is there any way ...

Guide for updating the background color, font color, and border color in Material UI's autocomplete textfield

How can I customize the appearance of this material-ui autocomplete textfield (combobox) by changing the background color, font color, and border color using CSS? Here is what I have attempted so far: <Autocomplete disablePortal id=" ...

Removing information from the database using a JSP webpage

Having some issues with my online reservation system. The problem lies in the code where users are unable to cancel their reservations using the cancel button on the jsp page. It seems that the code is not properly deleting data from the database. Any sugg ...

What is the method of adding a child to the outerHTML of the parent element instead of within it?

Is there a way to use the outerHTML method on a parent element to append a child element so that the icons appear outside of the targeted element rather than inside it? The current code snippet shows the icons inside the box, but I want them to be placed o ...

What's the easiest method for moving div content from side to side?

Working on a plugin for WordPress, I am faced with the task of moving content in a slider from left to right and right to left. My current attempt is as follows: var effect = 'slide'; // Set the options for the chosen effect type var opti ...

How can I align a single button to the left side while positioning the rest of the elements to the right in Bootstrap 4?

I am attempting to align the B1 button on the left side and have the remaining elements positioned on the right side. Below is my code snippet using Bootstrap 4.1: <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/b ...

Angular CSS: ng-style applied to only one side, the other remains unaffected

I am working on an Angular application that requires a split screen with two halves, each displaying the same array values. The width and height values are set using a service and accessed by a controller. The style is applied using ng-style in the DOM. Ho ...

What is the best way to synchronize the image dimensions and source when dynamically loading images?

I am facing an issue with a function that updates images by altering the src and css (width/height) of an IMG tag within the document. Below is a simplified example to demonstrate the problem: updateImage = function(src, width, height) { $("#changeMe"). ...

How do you add dynamic content to modals in AngularJS and Angular Strap based on the button that was clicked?

Is there a way to make the buttons in the AngularJS + AngularStrap modal more dynamic? Currently, they display static content, but I would like them to show the content of the first column (first name) of the exact row where the button was clicked. What is ...

Using CSS to conceal an element when a different element is also invisible

My inquiry is as follows: I currently possess a code that conceals class element 1 when it possesses a specific value (which varies across different sites). Now, my objective is to also conceal class element 2 ONLY IF class element 1 is already hidden. ...

Having trouble with a basic API Get request?

I'm trying my hand at making a simple get request to fetch a random quote from an API. When I hardcode the change of the quote on button click, everything works smoothly. $(document).ready(function() { $("#quotebtn").on('click', functio ...

What is the solution to eliminating the horizontal scroll bar on a responsive website?

Currently in the process of developing a responsive website, I have encountered an issue with excess empty space appearing on the right side when scrolling horizontally. Utilizing overflow-x: hidden successfully eliminates the horizontal scroll; however, t ...

Tips for receiving accurate HTML content in an Ajax request

I have used an Ajax call to fetch data from a function that returns an entire HTML table. $.ajax({ url: "/admin/project/getProjectTrackedTimes", headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('cont ...

Extract the HTML field value from an AJAX drop-down selection, rather than relying on user input

I have a field that allows users to select from a dropdown list using the following code: $(function() { $('.serial_number').live('focus.autocomplete', function() { $(this).autocomplete("/admi ...

Is there a way to maintain image proportions when resizing the window?

I'm in the process of developing a classroom-themed website with interactive overlaying images. The goal is to have various pictures that users can click on to access different resources from different websites. My main challenge right now is getting ...