Bootstrap Table with Vertical Heading that Responds to Different Screen Sizes

Having an issue with Bootstrap responsive table functionality: it works well for tables with horizontal headings, but I'm struggling to achieve the desired layout for my table with vertical headings.

I have several 2-column tables for specifications that are structured like this:

<table class="table-responsive">
    <tr>
        <th>FRAME</th>
        <td>ALUMINUM</td>
    </tr>
    <tr>
        <th>POWER</th>
        <td>500W</td>
    </tr>
    <tr>
        <th>BATTERY</th>
        <td>9</td>
    </tr>
    <tr>
        <th>WEIGHT</th>
        <td>45KG</td>
    </tr>
    <tr>
        <th>PRICE</th>
        <td>333$</td>
    </tr>
</table>

Everything looks fine on desktop view, but on mobile devices, the text gets squished together and becomes unreadable. My goal is to allocate 30% width for the th elements, fill the remaining 70% with td content, and enable horizontal scrolling if necessary to keep the table legible on smaller screens.

Answer №1

One way to customize your website's appearance is by using media queries to tailor your styling

// For small devices such as landscape phones (576px and larger)
@media (min-width: 576px) { 
  table-responsive th {
    width: 30%
  }

table-responsive td {
    width: 70%
  }
}

// Adjustments can also be made for medium devices like tablets (768px and larger)
@media (min-width: 768px) { 
  Feel free to make necessary changes for tablet view
 }

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

Attaching a CSS file to a personalized WordPress widget

After much searching and struggling due to language barriers or lack of PHP knowledge, I couldn't figure out how to achieve this: public function widget( $args, $instance ) { ?> <div style="padding: 0 0 14% 0"> <div class="m ...

Issue with a hidden div, problem with scrolling, a div overlapping other divs

I'm feeling a bit lost here, trying to figure out what went wrong. It seems like a simple mistake, but I can't pinpoint it. Currently, I'm just testing everything out for a mobile website template. Hopefully, that information helps. For any ...

In Internet Explorer 7, there appears to be a white box that covers up the content on our website beyond a

I'm feeling stuck and frustrated trying to solve this issue. I have a Mac and no access to an IE7 machine, so I've been using browserlab (which is slow) to make any changes and see if they help. Unfortunately, I haven't been able to fix the ...

Initiate Bootstrap 4 dropdown menus from the initial menu point

I need the dropdown menus to align with the position of the first dropdown. There are multiple dropdowns on the page. Check out the screenshot for reference. JSFiddel: https://jsfiddle.net/kfh9Lbep/ https://i.sstatic.net/hHAKz.png Any ideas on how to ac ...

The <img> tag is displaying with dimensions of 0 x 0 pixels even though its size was specified

Is there a way to control the image size within an <img> tag placed inside an html5 video element? Currently, it keeps defaulting back to 0 x 0 pixels. The reason behind using this img is to serve as a fallback for outdated browsers where the video ...

Having trouble with this code// Does anyone know how to make the div slide in line with other divs when hovering over it?

After spending countless hours analyzing and trying various solutions, I have come to the realization that I need to seek help with my code. The task at hand is proving to be incredibly frustrating, and I have exhausted all other options before resorting t ...

JavaScript Refresh Function Malfunctioning

Currently, I have a JavaScript code snippet on my website that automatically refreshes an iframe every three seconds. window.setInterval(function() { reloadIFrame() }, 3000); function reloadIFrame() { var frame = document.getElementById("if ...

What is the best way to ensure that my top menu remains fixed while scrolling?

Link to website: I am looking to have the top menu on my page remain fixed at the top of the screen as users scroll. Does anyone know if this is achievable, and if so, how can I implement it? ...

Transmitting form data inputted by the user to a modal that resides in the same component, all without the need for child or parent components or

In need of a solution where users can input answers to questions and have all the entered data displayed in a popup alongside the respective question. If a user chooses not to answer a question, I do not want that question or any related information to be ...

A-Frame's video and video sphere functionalities do not function properly on mobile and tablet devices

When using A-Frame, I've encountered issues with video and video sphere not auto playing. This is because mobile browsers typically require a user action to initiate video playback. I've tried implementing a click event to play the video, but it ...

Hover over an element to trigger the background fading effect on the parent div

I'm looking to create a hover effect on an element within a fullscreen div. When I hover over the element, I want a background image to fade in on the div with the class ".section." While I can easily display the background image, I am unsure of how t ...

Issue with Wordpress css rendering on Internet Explorer

My webpage is functioning well in Chrome and Firefox, but I'm facing compatibility issues with Internet Explorer. I've identified several bugs related to tables and layout, however, I'm struggling to resolve the font and text-transform prob ...

Differences between -webkit- and -moz-transition

My website uses CSS3 transitions and I have noticed that the -webkit- prefix works, but the -moz- prefix does not seem to be working. This is the CSS code I am using: article {z-index: 2; float: left; overflow: hidden; position: relative; -webkit-transit ...

Despite having seemingly correct code, Handlebars is not entering the condition and no errors are being generated

Can someone help me identify the issue with this handlebars code snippet? Here's how it appears: {{#ifEquals "ciao" "ciao"}} <h1>########################</h1> {{/ifEquals}} Below is the helper function associated with it: Ha ...

What is the most effective way to align a thumb to the left and content to the right?

What is considered the optimal method for positioning an image to the left with two text fields to the right of it? Is using floats or positioning better? <li> <a href=""> <img src=""THUMB HERE /> </a> <a href=""> TITLE </ ...

Tips for altering the text color of the highlighted row in a Material UI table

Trying to modify the color of the row text and the background color when selected. I have managed to adjust the background color, but I am encountering difficulty changing the text color. <TableRow className={classes.tableBody} > tab ...

Can CSS masking work on all web browsers?

Is there a method to apply masks in CSS that function properly in Firefox? I've searched extensively, but it must be doable. I came across a code snippet using mask: ('mask.svg#mask'); but unfortunately, it's not effective! ...

Vue 3's Paged.js does not respond to requests for page breaks

Currently, I'm working on implementing page breaks in Vue.js 3. Despite my efforts and utilization of the specified CSS code, I am facing challenges with the ".page-break" class parameter. While I can successfully modify other elements like titlePage ...

How to set a custom height for Mat-form-field in Angular 8 using pixel values

Is there a way to adjust the height of mat-form-field when using appearance="outline" to a specific pixel measurement, such as 40px (or any other value required by the UX team in the future)? I need to decrease the size of the mat-form-field. How can this ...

Troubleshooting jQuery Dropdown Menu Animation Bugs

Take a look at this interesting fiddle: https://jsfiddle.net/willbeeler/tfm8ohmw/ HTML: <a href="#" class="roll-btn">Press me! Roll me down and up again!</a> <ul class="roll-btns"> <li><a href="#" class="control animated noshow ...