Tips for creating a responsive table that adjusts to the width of the column in Bootstrap/CSS

I need help adjusting my Bootstrap table to fit the width of a col-md-5 column without overflowing into the adjacent invoice template table. I attempted to use the .table-responsive class, but it didn't solve the issue. My current version is Bootstrap 4.

This snippet shows my layout:

{%  extends 'base.html' %}
{%  block content %}
<!DOCTYPE html>
<html lang="en">
    <body>
        <div class ="row">
            <div class="col-md-5">
                <div class="table-responsive">
                    <table class="table">
                      <thead>
                        <tr>
                          <th scope="col" >Photo</th>
                          <th scope="col">Name</th>
                          <th scope="col">ERP number</th>
                          <th scope="col">Unit</th>
                          <th scope="col">Price (USD)</th>
                          <th scope="col">Price (EUR)</th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr>
                          <th scope="row">product.photo</th>
                          <td>product.item_name</td>
                          <td>product.erp_number</td>
                          <td>product.unit</td>
                          <td>product.price_usd</td>
                          <td>product.price_eur</td>
                        </tr>
                      </tbody>
                    </table>
                </div>
            </div>
            <div class="offset-md-5 col-md-7">
                {% include 'invoice.html' %}
            </div>
        </div>
    </body>
</html>
{%  endblock %}

UPDATED:

<html>
{% load staticfiles %}
{% load static i18n %}

<head>
  <meta charset="UTF-8>
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
  <title> Company| {% trans 'Witaj' %}</title>

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
    <link href='http://fonts.font.im/css?family=Poiret+One|PT+Serif|PT+Sans|Pacifico|Satisfy' rel='stylesheet' type='text/css'>
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <link href="video-js.min.css" rel="stylesheet">
    <script src="video.min.js"></script>
    <script src="https://cdn.WebRTC-Experiment.com/RecordRTC.js"></script>
    <script src="wavesurfer.min.js"></script>
    <script src="wavesurfer.microphone.min.js"></script>
    <script src="videojs.wavesurfer.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <link href="{% static 'main/style.css' %}" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.2.0/css/all.css" integrity="sha384-hWVjflwFxL6sNzntih27bfxkr27PmbbK/iSvJ+a4+0owXq79v+lsFkW54bOGbiDQ" crossorigin="anonymous">

    {% block head_extra %} 
       <!-- any additional head content goes here -->
    {% endblock head_extra %}

</head>

@Tieson T: It does now. However, despite restarting the local server, no visible changes occurred.

Answer №1

It is recommended to make a change in your CSS code by updating

.table-responsive { overflow-x: none; }

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
}

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

What is the most effective method for incorporating a floating section next to a Susy gallery?

Check out my latest progress on the codepen here The number of items displayed in the gallery is dynamic based on search results. However, I am looking to add a fixed area to the right side that remains visible as the user scrolls through the gallery. Ess ...

Is there a way to adjust the position of the scrolling bar to be closer to the post area?

I was exploring this page (http://noahsdad.com/state-fair-texas-2011/) and noticed a scrolling sidebar to the left of the content area. I'm looking to adjust it so that it is closer to the content area. Any suggestions on how to achieve this? Thank y ...

WordPress footer widgets appearing misaligned

I have made a child theme for Twenty Thirteen and am in the process of making some updates to it. My development site is essentially a replica of the live site. The only modification I made in the footer section was to change the widget title styles, but I ...

Tips for eliminating the white focus color from the login and password form

Every time I attempt to log in and input my credentials on the login form, a white box appears which looks strange. Is there a way to remove it? https://i.sstatic.net/gazZp.png I have implemented three classes in the login form: .login-form, .form-contro ...

Height of Bootstrap 4 footer aligned to the bottom

I've made a template that sets the height of the footer to 120px and specifies the line-height as well. Here is an example: .footer { height: 120px !important; line-height: 120px !important; } <!doctype html> <html lang="en"> &l ...

"Utilizing Bootstrap's hamburger menu for a sleek solution when your menu becomes overcrowded

One interesting aspect of Bootstrap is its ability to collapse menu items into a hamburger menu within the navbar at specific window size breakpoints. However, there are instances where even on larger screens that exceed these breakpoints, the hamburger bu ...

What is the best way to insert space between spans in HTML when designing email templates?

I am currently designing email templates, which means I have some limitations. Although I have used align="center", I still require some spacing between the two spans. How can I achieve this? CODE: <td width="659" height="28" bgcolor="#999999" align= ...

What is the best way to position an arrow in relation to a circle?

I'm struggling to center the arrow in relation to the circle How can I switch the arrow direction to point downwards when viewed on mobile, so that the images are stacked vertically with downward arrows? Here is the code snippet that I have experimen ...

Bootstrap 4.6 - new feature: flexible vertical pills and sleek horizontal tabs (inactive tab no longer highlighted)

I recently implemented Bootstrap 4.6 into my project. The page I am working on includes both vertical pills and horizontal tabs. While the vertical pills are displaying correctly, I have encountered an issue with the styling of the horizontal tabs when th ...

Link causing chaos in CSS animation

I've created a CSS animated banner. You can view the result here. However, I'm facing an issue where adding a hyperlink to some of the pictures is causing the animation to mess up. The first picture has a href attribute, making it smaller and not ...

Creating a wider background color for active nav bar links in CSS - A step-by-step guide

I've been working on customizing a CSS navbar and I've managed to get it to work as desired. However, I'm facing an issue with the active state background color, which seems to be the same width as the text itself. I've spent hours sear ...

What could be the reason why the navbar ul li a instance is not appearing in Bootstrap 4 modal when using an

Can anyone help me solve the issue I'm having with viewing HTML in a Bootstrap 4 modal? Everything shows up except for the navbar ul li a elements. I've searched for a solution everywhere, but haven't found one yet. Please assist! (I want t ...

Content displayed in the center of a modal

Struggling to center the captcha when clicking the submit button. Check out the provided jsfiddle for more details. https://jsfiddle.net/rzant4kb/ <script src="https://cdn.jsdelivr.net/npm/@popperjs/<a href="/cdn-cgi/l/email-protection" class=" ...

What is the best way to shift the lower section to align with the right side of the rest of the headers and text blocks?

Help needed with moving the Uni section to align it beside other paragraphs and headers. Tried using float left but no luck so far. Any suggestions would be appreciated! Check out the code here <div class ="container"> <div id="education" class ...

Ways to customize the appearance of a specific column in a k-grid td

While working with a kendo grid, I encountered an issue with setting a tooltip for one of the columns. After some experimentation, I discovered that in order for the tooltip to display correctly, I needed to override the overflow property on the k-grid td ...

Unable to increase font size using CSS

I am struggling with adjusting the size of an h1 element along with other properties, but the only change I see is in the font family. Could it be the Bootstrap grid I am using causing this issue? I am still relatively new to Bootstrap. h1{ font-famil ...

Trouble pausing CSS slide using -webkit-animation-play-state:paused; finding it ineffective

Below is the code snippet in question: .picTransition .item { position: absolute; left: 0; right: 0; opacity: 0; -webkit-animation: picTransition 56s linear infinite; -moz-animation: picTransition 56s linear infinite; -ms-animation: ...

What are some techniques for utilizing CSS with form.ImageField in Django?

When attempting to apply CSS to form.ImageField in Django similar to CharField, I encountered an error. File "/Users/hogehoge/Desktop/hoge/hoge/forms.py", line 42, in PostForm photo = forms.ImageField(label='Image', validators=[fi ...

Definition list with alternating left and right alignments

Here is a definition list with a specific styling: dl { margin: 0; } dl.interview dt { color: #A8A67A; } dl.interview dd { margin-left: 0; } .interview dt:before { content: 'Q. '; } .interview dd:before { content: 'A. ...

Positioning bar chart columns and text using CSS

My component generates HTML for a simple bar chart, with the height and background color computed within the component. Everything functions correctly, but I am facing an issue where long text causes displacement of the bar above it. Another problem is th ...