StuckCoder50
StuckCoder50
KPCKevin Powell - Community
Created by StuckCoder50 on 5/19/2024 in #front-end
Centering HTML form
Im trying to display my login form in the middle of the page instead of the top, but i cant figure out how to. I have tried giving the form an id, a class n applying css to those. I have also tried wrapping the form in a div but it dint work. login.html code:
{% extends "layout.html" %}

{% block title %}
Log In
{% endblock %}

{% block body_class %}
login-page
{% endblock %}

{% block main %}
<h1>Log In</h1><br>
<form action="/login" method="post">
<div class="mb-3">
<input autocomplete="off" autofocus class="form-control mx-auto w-auto" name="username" placeholder="Username" type="text">
</div>
<div class="mb-3">
<input class="form-control mx-auto w-auto" name="password" placeholder="Password" type="password">
</div>
<button class="btn btn-primary" type="submit">Log In</button>
</form>
{% endblock %}
{% extends "layout.html" %}

{% block title %}
Log In
{% endblock %}

{% block body_class %}
login-page
{% endblock %}

{% block main %}
<h1>Log In</h1><br>
<form action="/login" method="post">
<div class="mb-3">
<input autocomplete="off" autofocus class="form-control mx-auto w-auto" name="username" placeholder="Username" type="text">
</div>
<div class="mb-3">
<input class="form-control mx-auto w-auto" name="password" placeholder="Password" type="password">
</div>
<button class="btn btn-primary" type="submit">Log In</button>
</form>
{% endblock %}
25 replies