【发布时间】:2020-05-05 15:54:07
【问题描述】:
我正在使用引导程序制作一个 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 %}
这里是页面图片的链接! PREVIEW
我试图解决这个问题,但我做不到。即使我也检查了 Bootstrap 的文档,我一定做错了什么......
【问题讨论】:
-
您是否尝试在主
div上添加.justify-content-center?如果我是你,我会将所有内容都包装在.container或.container-fluid中,然后是.row(指定.col的数量)并在.row上添加.justify-content-center,看看是否工作。
标签: python html flask web-applications