Как сделать так, чтобы таблица автоматически соответствовала ширине столбца в Bootstrap / CSS - PullRequest
0 голосов
/ 13 октября 2018

Я хотел бы подогнать мою таблицу в Bootstrap к ширине столбца, равной col-md-5, но на самом деле она перетекает в следующую таблицу, которая является шаблоном счета.Я пытался использовать класс .table-responsive, но он не работает.Я использую Bootstrap 4.

Это мой шаблон:

{%  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 %}

ОБНОВЛЕНО:

<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 %} {% endblock head_extra %}

</head>

@ Tieson T: Теперь.Но ничего не изменилось ... Я перезапустил локальный сервер.

1 Ответ

0 голосов
/ 13 октября 2018

Пожалуйста, обновите ваш код CSS в .table-responsive { overflow-x: none; }

.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: -ms-autohiding-scrollbar;
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...