使用 CSS 使表单居中

Centering a form with CSS

我在 html/css 中使用以下代码编写了一个表单:

.login_form_wrapper{
float:left;
padding:60px;
width:55%;
padding:80px 100px 78px 100px;
text-align:center;
}

如何将 居中以使其整齐地适合用户屏幕的中心?

过去几个小时我一直在尝试编辑 CSS,但没有任何乐趣。

如有任何帮助,我们将不胜感激。

干杯

将此添加到样式中 class

.login_form_wrapper{

    position: sticky;
    left: 25%;
    margin-left: -50px;
}

我在 inspector 里玩了几分钟,发现这个 css 看起来不错。

.login_form_wrapper {
    margin : 0 auto;
    width: 100%;
}

我想你用的CSS 类不止一个地方用过。导致你的问题的原因是在这个包装器上 DIV:

<div class="login_form_wrapper register_wrapper">

您 类 正在申请 float: left; 这需要删除并添加 margin: 0 auto;