Html 我正在使用引导,无法将窗体居中

Html 我正在使用引导,无法将窗体居中,html,css,forms,bootstrap-4,Html,Css,Forms,Bootstrap 4,琼伯伦先生{ 背景图片:urlbackground.jpg; 颜色:白色; 文本对齐:居中; } 我最棒的应用程序 这就是为什么你应该下载这个奇妙的应用程序 想知道更多吗 加入我们的邮件列表 现在就报名吧 您的表单是一个flex容器,flex可以水平居中 证明内容:中心;垂直对齐项目:如果高度足够,则居中对齐 添加下面的css,这将使表单居中 .form-inline { justify-content: center; } 如果您使用的是bootstrap和,我建议您严格使用它。将表单包围

琼伯伦先生{ 背景图片:urlbackground.jpg; 颜色:白色; 文本对齐:居中; } 我最棒的应用程序

这就是为什么你应该下载这个奇妙的应用程序

想知道更多吗

加入我们的邮件列表

现在就报名吧 您的表单是一个flex容器,flex可以水平居中 证明内容:中心;垂直对齐项目:如果高度足够,则居中对齐

添加下面的css,这将使表单居中

.form-inline {
 justify-content: center;
}

如果您使用的是bootstrap和,我建议您严格使用它。将表单包围在容器、行、列中。如果您想提供填充或边距,请使用引导类。 在这种情况下:

<div class="container">
    <div class="row justify-content-center">
        Your Form goes here
    </div>
</div>

请看这里:https://getbootstrap.com/docs/4.4/layout/grid/

在表单中,内联显示设置为flex,以便您可以添加内容:中心;或者您可以在html中将资源中心添加到类属性中。

将此类添加到容器类中

<div class="row justify-content-center">
    Your Form
</div>


通常,父元素会阻止元素按需要对齐。它不仅限制了中心,还限制了浮动。 请检查父元素的宽度。希望这对您有所帮助。

显然您正在使用引导,因此请尝试以下方法:

<div class="container"> <div class="row justify-content-center"> Your Form  </div> </div>

谢谢这是个好建议。我应该更好地利用网格系统。如果你觉得有用,你应该选择一个答案,并澄清问题已经解决。
<div class="container"> <div class="row justify-content-center"> Your Form  </div> </div>
form-inline{
       justify-content:center
}