Python Boostrap div内容对齐中心?

Python Boostrap div内容对齐中心?,python,html,flask,web-applications,Python,Html,Flask,Web Applications,我正在用bootstrap制作一个web应用程序,我想把我的div内容放在页面和表格的中心,所以我需要帮助。这是我的代码和下面页面的预览。提前谢谢 {% extends 'base.html' %} {% block head %}<title>{{ title }}</title>{% endblock %} {% block content %} <div class="content-section bg-white border border-p

我正在用bootstrap制作一个web应用程序,我想把我的div内容放在页面和表格的中心,所以我需要帮助。这是我的代码和下面页面的预览。提前谢谢

{% extends 'base.html' %}

{% block head %}<title>{{ title }}</title>{% endblock %}

{% block content %}
    <div class="content-section bg-white border border-primary mx-md-n5 shadow-lg px-5 mt-auto">
        <form method='POST' action=''>
            {{ form.hidden_tag() }}
            <fieldset class="form-group">
                <legend class="border-bottom mb-3">Calculate BMI</legend>
                <div class="form-group">
                    {{ form.weight.label(class="form-control-label mb-3") }}
                    {% if form.weight.errors %}
                        {{ form.weight(class="form-control form-control-lg is-invalid") }}
                        <div class="invalid-feedback">
                            {% for error in form.weight.errors %}
                                <span>{{ error }}</span>
                            {% endfor %}
                        </div>
                    {% else %}
                        {{ form.weight(class='form-control form-control-lg') }}
                    {% endif %}
                </div>
                <div class="form-group">
                    {{ form.height.label(class="form-control-label mb-3") }}
                    {% if form.height.errors %}
                        {{ form.height(class="form-control form-control-lg is-invalid") }}
                        <div class="invalid-feedback">
                            {% for error in form.height.errors %}
                                <span>{{ error }}</span>
                            {% endfor %}
                        </div>
                    {% else %}
                        {{ form.height(class='form-control form-control-lg') }}
                    {% endif %}
                </div>
                <div class="form-group">
                    {{ form.submit(class="btn btn-danger btn-block")}}
                </div>
                <small><i>Formula: [Weight(kg)/Height²(cm²)] * 10000</i></small>
            </fieldset>
        </form>
    </div>
    <hr class="border border-primary shadow-lg mx-md-n5">
    <table class="table table-responsive-md mx-md-n5 shadow-lg table-bordered table-hover">
        <thead class="thead-dark">
            <tr>
            <th scope="col">Table</th>
            <th scope="col">Low Body Weight</th>
            <th scope="col">Normal Weight</th>
            <th scope="col">Overweight</th>
            <th scope="col">Adipositas</th>
            <th scope="col">Too Overweight</th>
            </tr>
        </thead>
        <tbody>
            <tr>
            <th scope="row">BMI:</th>
            <td> < 19 </td>
            <td>19-24</td>
            <td>25-29</td>
            <td>30-40</td>
            <td> > 40 </td>
            </tr>
        </tbody>
    </table>


{% endblock %} 
{%extends'base.html%}
{%block head%}{{title}{%endblock%}
{%block content%}
{{form.hidden_tag()}}
计算体重指数
{{form.weight.label(class=“form control label mb-3”)}
{%if form.weight.errors%}
{form.weight(class=“form control form control lg无效”)}
{form.weight.errors%中的错误为%s}
{{error}}
{%endfor%}
{%else%}
{{form.weight(class='form-control form-control lg')}
{%endif%}
{{form.height.label(class=“form control label mb-3”)}
{%if form.height.errors%}
{{form.height(class=“form control form control lg无效”)}
{%表示form.height.errors%中的错误}
{{error}}
{%endfor%}
{%else%}
{{form.height(class='form-control form-control lg')}
{%endif%}
{{form.submit(class=“btn btn danger btn block”)}
公式:[重量(kg)/高度(cm²)]*10000

桌子 低体重 正常重量 超重 脂肪症 超重 体重指数: < 19 19-24 25-29 30-40 > 40 {%endblock%}
这里是一个链接到该页面的图片!


我试图解决这个问题,但就是做不到。我一定是做错了什么,尽管我也检查了引导的文档…

为了使任何资源中心在引导中对齐,我总是使用非常基本的技巧。无论您使用的是哪种,只需将文本中心写入类属性的值中即可。如果您已经在使用任何其他类,只需在其旁边输入文本中心即可

比如说。请参阅下面的代码片段

<div class="content-section text-center">

此外,您还可以使用引导网格系统,即row和col类,根据您的要求对齐内容


希望您能

您是否尝试在主
div
上添加
.justify资源中心
?如果我是你,我会把所有东西都装在一个
.container
.container fluid
中,然后再装一个
.row
(指定
.col
的数量),然后在
.row
上加上
.justify content center
,看看是否有效。我相信他们正在寻找整个
div
集中在页面上,不是要在
div中集中的内容
是的,我正在寻找整个div的中心,我已经找到了它,谢谢你们两位的支持!