Creating a dynamic table layout with Bootstrap

Can someone help me figure out how to make this table responsive using Twitter Bootstrap 4? Here's the JS Fiddle Link for reference.

<div class="some-table-section">
<div class="container">
    <table class="table some-table">
        <thead>
            <tr>
                <th scope="col"></th>
                <th scope="col">Plan 1</th>
                <th scope="col">Plan 2</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <th scope="row">Option 1</th>
                <td>$1</td>
                <td>$2</td>
            </tr>
            <tr>
                <th scope="row">Option 2</th>
                <td>1</td>
                <td>2</td>
            </tr>
            <tr>
                <th scope="row">Option 3</th>
                <td>Unlimited</td>
                <td>Unlimited</td>
            </tr>
            <tr>
                <th scope="row"></th>
                <td><a href="#" class="btn btn-primary">Select this plan</td>
                <td><a href="#" class="btn btn-primary">Select this plan</td>
            </tr>
        </tbody>
    </table>
</div>
</div>

Seeking a solution to create a responsive version of this table where plan 2 appears below plan 1 in the responsive view. For current CSS, visit the JS Fiddle Link.

Answer №1

If you need guidance on creating responsive tables, make sure to refer to the Bootstrap Docs at https://getbootstrap.com/docs/4.3/content/tables/#responsive-tables

To make your table responsive, all you have to do is wrap it with .table-responsive

Here's a basic example:

<div class="table-responsive">
    <table class="table">
        ...
    </table>
</div>

If you want a responsive table that adjusts based on different breakpoints, you can use classes like

table-responsive{-sm|-md|-lg|-xl}

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

li tag style

I need to insert a check mark inside the <li> tag on the right side. How can I do this? The check mark looks like this: For example: http://jsfiddle.net/HpVcy/ ul li{ padding: 3px 10px 3px 10px; background:url(http://img4up.com/up2/730897458613759 ...

Enable CDATA support in ActionView::Base.full_sanitizer

One method I found helpful was using the ActionView::Base.full_sanitizer.sanitize(value) to remove HTML content. It generally works well, but there is an issue when the value passed into the method is wrapped in <![CDATA[ and ]]> because it returns a ...

Using Responsive Design with Bootstrap and Media Queries

As a beginner in front-end development, I have recently learned about media queries and their functionality. Having previously studied Bootstrap, I can't help but wonder if media queries are actually necessary. After all, Bootstrap seems to offer simi ...

What is the best way to send data to PHP while moving objects between different div elements?

I have a situation where I have two parent divs containing dynamic children divs, and I want to enable POST requests to PHP when items are dragged from one side to the other (and vice versa). Here is the Javascript code I am using: function allowDrop( ...

Combining HTML with multiple .ts files in Angular

I've been dedicating time to enhancing an Angular application, particularly a sophisticated table with intricate styling and functionality. Within my component file, there is a whopping 2k lines of code that includes functions for text formatting, ta ...

Obtaining an identification using JQuery for content that is constantly changing

I am currently developing dynamic content tabs using PHP, with one of the objects being a datatable within the tab. In order to define the ID via PHP, I use the following code: PHP: echo '<table class="table table-striped table-bordered table-hov ...

HTML5 allows users to choose data from a list using a ComboBox and submit the 3-digit code

I'm looking to enhance my form by including an input box where users can select airports, similar to the functionality on this website (). When typing in the Destination Input, I want users to see a list of possible values with detailed suggestions su ...

Vue.js V-for not rendering any content

I am currently working on populating an array with objects retrieved from an API. The objects are being fetched successfully, but I am facing issues when trying to display them using v-for in the array. Below are my data variables: data() { return { ...

What is the best way to position a <label> to the left of an <input> field?

Examining the HTML and CSS code below: * { box-sizing: border-box; } .field { overflow: auto; } .field label { float: left; width: 80px; } .field input { display: block; width: 100%; } <div class="field"> <label>Test< ...

An error occurred: Reaching the maximum call stack size when utilizing the .map function in jQuery

Encountering a console error: Uncaught RangeError: Maximum call stack size exceeded This is the jQuery snippet causing trouble: $(document).on("change","select.task_activity", function(){ selected_activity = $("select.task_activity :selected").map(fu ...

Change the color of the text to be the opposite of the background

I'm facing a challenge while creating a website for my friend. The background of the site is a moving image, and I want the font color of the main title to be the opposite of it on each frame. While I know this may require CSS, I am unsure of how to ...

Is there a way to extract shared properties within a Material UI style declaration?

I am working with a specific set of style rules that define different statuses: status_in_progress: { fontSize: 14, backgroundColor: theme.palette.success.dark, padding: 2, paddingLeft: 5, paddingRight: 5, display: "inline-bl ...

Mastering CSS: Optimizing Div Placement Across Sections

I am currently working on developing a sleek and modern landing page with multiple sections, each designed to catch the eye. This style is all the rage at the moment, featuring large headers, ample padding, bold text, and a visually appealing divider betwe ...

The `innerHTML` function is responsible for closing HTML

My switch structure is set up as follows: switch (ratio) { case "16:9": imgContainer.innerHTML = '<img src="images/test-rata-de-aspect.jpg">' break case "4:3": imgContainer.innerHTML = '<img src="image ...

Is there a function called 'onViewportChange' in media queries that triggers a search in the .css file for applicable styling?

So I'm not entirely sure about all the specifics, but my understanding is that each time a new HTML element is created, it checks through all linked CSS files and inline styles to see if those styles should be applied to that element. This suggests t ...

How can I manage the horizontal scrolling in a large, expansive HTML Bootstrap table?

Currently, I am working on a Laravel project and have encountered an issue with a table that is overflowing from the right side. Despite trying various methods for implementing horizontal scroll, none of them seem to be effective in resolving the problem. ...

What is the problem with locating elements in Selenium with Java?

I've been encountering difficulties in finding elements on a webpage structured like this: <tr id="filter100" style="...." idx=0 <td> <div onclick=... style=... <table dir = "fil"> <tbody> ...

How to position radio buttons in line with labels containing inline inputs using Vue and Bootstrap

Currently, I am facing an issue with my form containing a radio button group where one of the radio button labels includes another numerical input. The layout is not aligned correctly, and I am struggling to adjust the spacing using CSS. I am unable to gr ...

Discover an effective way to display Ajax search results above a different div element!

I am having trouble with positioning my search results on top of other divs. To see the issue, you can watch the screen recording by clicking on this link: https://drive.google.com/file/d/1kU_vl2ZAmSCok0pxnTTvY hacxqcZZ9m_/view?usp=sharing These are the s ...

Dynamic Image Grid Created Using JavaScript Glitches

My dilemma involves using JQuery to create an HTML grid of images styled with Flex Boxes. The setup works perfectly on desktop, but when viewing it on mobile devices, the images begin to act strangely - jumping, overlapping, and even repeating themselves i ...