<div class="card border-dark bg-white text-dark" style="width: 400px; height: auto; margin :10px auto ">
<div class="card-header">
<h3>Register to REFILM</h3>
</div>
<div class="card-body">
<form action="/register" method="post">
<div class="mb-3">
<input autocomplete="off" autofocus type="text" class="form-control" name="username" placeholder="Username">
</div>
{% if username_error %}
<div class="alert alert-danger" role="alert">
{{ username_error }}
</div>
{% endif %}
<div class="mb-3">
<input type="password" class="form-control" name="password" placeholder="Password">
</div>
{% if password_error %}
<div class="alert alert-danger" role="alert">
{{ password_error }}
</div>
{% endif %}
<div class="mb-3">
<input type="password" class="form-control" name="confirmation" placeholder="Confirm password">
</div>
{% if confirmation_error %}
<div class="alert alert-danger" role="alert">
{{ confirmation_error }}
</div>
{% endif %}
<div class="col text-center">
<button type="submit" class="btn btn-primary">Register</button>
</div>
</form>
</div>
</div>
我正在使用引导程序中的卡属性创建一个注册窗口。但这很奇怪,因为卡片的高度充满了屏幕。
我已经尝试过在父标签和子标签上设置 height: auto 等设置,但它仍然是相同的。
解决方案:移除卡体标签
style="height:300px"
您是否尝试过将高度放入卡体CSS中?
我将使用实用程序类和最大高度自定义样式的混合来生成它。具体来说,vh-100 告诉它占据 100% 的水平视口,但在样式标签中包含“maximum-height:400px”以设置 400 像素的上限。
因此,将您的卡标签更改为:
<div class="card border-dark bg-white text-dark w-50 vh-100" style="max-height:400px" >
我只是把fit-content放在css标签里,高度就自动调整了!