Creating a responsive table using Bootstrap is easy and efficient

Looking for assistance in making a responsive table. Everything looks fine at full size: https://i.sstatic.net/xKSLi.png

but when the screen size is reduced I end up with something like this: https://i.sstatic.net/x0kwc.png

The table is displayed on col-md-7:

<div class="row">
                    <div class="col-md-7">
                        <div class="ritekhela-fancy-title-two">
                            <h2>Turnyrinė lentelė</h2>
                        </div>

                        <div class="rs-point-table sec-spacer">
                            <div class="tab-content">
                                <table>
                                    <tr>
                                        <td>Vieta</td>
                                        <td class="team-name">Komanda</td>
                                        <td>Sužaista</td>
                                        <td>Perg.</td>
                                        <td>Lyg.</td>
                                        <td>Laim.</td>
                                        <td>Įm.</td>
                                        <td>Pr.</td>
                                        <td>+/-</td>
                                        <td>Taškai</td>
                                    </tr>
                                    <tr>
                                        <td>01</td>
                                        <td class="team-name">Banani FC</td>
                                        <td>60</td>
                                        <td>35</td>
                                        <td>08</td>
                                        <td>16</td>
                                        <td>02</td>
                                        <td>04</td>
                                        <td>11</td>
                                        <td>95</td>
                                    </tr>
                                   </table>
                            </div>
                        </div>
                    </div>

UPDATE: When attempting to set max and min width, the designated area shrinks too much: https://i.sstatic.net/k6m7F.png

Answer №1

Upon reviewing your second example, it appears that the issue lies within your title bar, specifically in the elements enclosed by the class ritekhela-fancy-title-two.

You have a surrounding div with the name row wrapping this class, which should be adjusted to accommodate the width of its nested content.

Given that the 'fit-content' property is not universally supported by all browsers (as mentioned here), you will need to set the width to 'auto' and treat it as an inline block instead.

Subsequently, the width of your ritekhela-fancy-title-two class should be set to 'auto', eliminating the float:left declaration or changing it to 'float:none'. This adjustment ensures that the container does not overflow on larger screens and expands appropriately based on the table width on smaller screens.

To see these modifications in action, please refer to the updated version on the fiddle provided.

The key CSS styles that were edited/added are as follows:

.row {
    width: auto;
    display: inline-block;
}

.ritekhela-fancy-title-two {
    float: none;
    width: auto;
    padding: 12px 20px 12px 60px;
    border-top: 7px solid;
    background: url(/css/images/transparent-pattren.png);
    position: relative;
    margin-top: 30px;
    background-color: #6c757d;
}

edit: Additionally, to correct the impact on other title bars below, adjust the height of the second row:

.ec-nextmatch {
    border: 1px solid #f3f3f3;
    border-top: none;
    background-color: #fff;
    margin-bottom: 60px;
    float: none;
    height: 90px;
    width: auto;
}

Furthermore, remove .ec-nextmatch from the CSS snippet below for the following result:

.ec-team-matches, .ec-match-countdown, .ec-match-countdown .countdown-row, .ec-ticket-button {
    float: left;
    width: 100%;
}

Answer №2

To simplify the process of adjusting font sizes and table cell widths, I suggest utilizing the Bootstrap responsive table utility. This feature enables the table to scroll horizontally without much effort. Here's how you can implement it:

...
<div class="tab-content table-responsive">
    <table class="table">
        ...
    </table>
</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

The Bootstrap class "text-right or text-end" does not seem to be functioning properly when applied to the <a> element

I've been attempting to apply the text-right or text-end classes to the anchor element at the end, but for some reason, it's not working as expected. I even tried using style="text-align:right !important;", but it still doesn't pro ...

Adding a timestamp to the src URL in HTML: A step-by-step guide

Looking for a way to implement cache busting in my index.html file. Take a look at the code snippet below: <body> <app-root></app-root> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="&l ...

Placing markers on a straight path

Struggling to create a CSS component where the first and last points don't align properly with the ends of the line. This component should be able to handle any number of points (between 1 and 4) without relying on flexbox. I have a React component ...

How can I keep the CSS3 animation playing even after the hover state ends?

When hovering over the small menu logo on my site, there's a subtle wiggle effect that I really like. However, I would prefer if the animation played all the way through before repeating. Here's the code I'm currently using: Here is my code ...

Generate text in reStructuredText with columns

I'm attempting to style a reStructuredText segment in the following layout: type1 : this type4 : this type7 : this type2 : this type5 : this type8 : this type3 : this type6 : this type9 : this I want to fill the page with tex ...

I attempted all possible solutions, but unfortunately could not achieve success. I encountered difficulty in adding the data-offset and even attempted implementing jQuery to no avail

I would greatly appreciate any assistance. Despite my efforts with jquery, I have been unable to make it work. Below is the code that I attempted to use: <body data-spy="scroll" data-target="#navbar" data-offset="80"> ...

Can responsive images be utilized with a DIV's background-image property?

For my website, I want to incorporate a variety of Thumbnails that are retrieved from a database and displayed in different sizes within a Masonry grid. Typically, I would use background-image:url(image.jpg); background-size: 100% 100%:, but I am aiming t ...

Seeking assistance with images for a website

I'm currently working on a school project where we are creating a website. However, I've encountered an issue with an image. It's a bit difficult to explain, so I've uploaded a video to help illustrate the problem. Essentially, I want t ...

The image fails to reach full width and does not expand correctly when I zoom out

At the bottom of my website, I have a bar for displaying certain content. However, I am facing an issue where the bar is not extending to cover the entire screen width despite having code in place to do so. The HTML code is quite basic: <div class="bo ...

Personalized AWS Cognito: Strategies for Tailoring Input Field Designs

MY CURRENT CHALLENGE: Within my Vue application, I am utilizing the AWS authenticator for managing login and signup processes. However, customizing its style has proven to be difficult due to the structure being built with shadow DOM elements. https://i. ...

Font rendering problems in browsers, issue with anti-aliasing

I am experiencing a significant issue with anti-aliasing when rendering fonts in web browsers. While everything looked great in my design software, the fonts appear jagged and unattractive when viewed on major browsers. The fonts I am using are 'Segoe ...

Struggling to Locate the Chat Element on Google Hangouts Using Selenium Python

Lately, I have been struggling with the selenium module in Python. I am attempting to create a script that can automatically send messages to my friends as requested by one of them. Although I can successfully log into Google Hangouts using Selenium, I am ...

What is causing the section to cover the navbar?

My content is overlapping the navbar on certain screen sizes, and I'm not sure why. Any ideas on how to fix this issue? Would wrapping everything in a container help? Currently using bootstrap v5.3.0-alpha1. Additionally, when I have a collapsed nav ...

Tips for configuring the navigation links on the current page using Bootstrap

In my Angular application, I have set up navigation links for home, about, notifications, and logout. However, when I click on the home link, it redirects me to the login page instead of remaining on the current page. I need the functionality to stay on ...

Display an image with a colored background using CSS

Most of you have probably noticed that images on Facebook come with a default background. How can I achieve a similar background color for images without using an additional div just for the background? My current codes do create a background color, but th ...

The initial display of jqGrid columnChooser may not show the expected effect on the first attempt

Trying to implement jqGrid in my project has been mostly successful, but I am encountering two specific issues: The first time the columnChooser is clicked, it does not display the effect when clicking the done button. However, it works as intended on th ...

Minimum number of cards in each column

I'm currently utilizing media queries to make sure that my card-columns are shown in a responsive manner. However, I have noticed that there is a minimum requirement of 2 cards in each column before it moves on to the next one (from left to right). T ...

Border color options for select boxes

Currently, I am working on my first Django-bootstrap project and dealing with a select box. I am trying to customize it so that when clicked, the border of the select box and its options turns yellow, which is working well. However, there is an additional ...

Unable to access the jumbotron in Angular with Bootstrap 5

Recently, I set up a brand new Angular installation and included Bootstrap 5 using the following command: npm install bootstrap --save After that, I updated the lines in the angular.json file to: "styles": [ "node_modules/bootstra ...

Tips for defining CSS class for tables using django_tables2

I am interested in utilizing the table design from Bootstrap that is showcased on this page: https://getbootstrap.com/docs/4.0/content/tables/ The table class I want to use is named "" My challenge lies in understanding how to incorporate this ...