# Centering the Login

**URL:** <https://forums.knack.com/t/centering-the-login/20483>\
**Category:** Get Answers\
**Created:** [July 17, 2026, 4:01am UTC](https://forums.knack.com/t/centering-the-login/20483 "2026-07-17T04:01:56Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph7](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Joseph7](https://forums.knack.com/u/Joseph7)\
**Post date:** [July 17, 2026, 4:01am UTC](https://forums.knack.com/t/centering-the-login/20483/1 "2026-07-17T04:01:56Z")

</div>

Is there a simple bit of CSS code to center the login view on the login page?

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [July 18, 2026, 12:35am UTC](https://forums.knack.com/t/centering-the-login/20483/2 "2026-07-18T00:35:02Z")

</div>

Hi @Joseph7, below is a slice of CSS I use to center the login view in Classic apps.  
Hope it’s useful!

```CSS
/* LOGIN VIEW FORMATTING
---------------------------------------------------------------------------------------------------- */
.kn-scene:has(.kn-login), #knack-reset-pass { max-width: 400px !important; margin-left: auto !important; margin-right: auto !important; text-align: center; } /* Set max width for login views */
.kn-login-form { max-width: 100%; } /* Increase login form width */
.kn-login .column.is-half, #knack-reset-pass .column.is-half { width: 100%; } /* Widen inputs in login forms */
.kn-login .kn-button[type="submit"], #knack-reset-pass .kn-button[type="submit"] { width: 100%; } /* Widen submit button in login forms */

```

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/e/e5ed395a43b6cf6733bb103812f89adf88095493.png)

---

<div class="post-metadata">

**Author:** ![Joseph7](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Joseph7](https://forums.knack.com/u/Joseph7)\
**Post date:** [July 19, 2026, 9:54pm UTC](https://forums.knack.com/t/centering-the-login/20483/3 "2026-07-19T21:54:27Z")

</div>

> [@StephenChapman](#):
>
> ```auto
> /* LOGIN VIEW FORMATTING
> ---------------------------------------------------------------------------------------------------- */
> .kn-scene:has(.kn-login), #knack-reset-pass { max-width: 400px; margin-left: auto; margin-right: auto; text-align: center; } /* Set max width for login views */
> .kn-login-form { max-width: 100%; } /* Increase login form width */
> .kn-login .column.is-half, #knack-reset-pass .column.is-half { width: 100%; } /* Widen inputs in login forms */
> .kn-login .kn-button[type="submit"], #knack-reset-pass .kn-button[type="submit"] { width: 100%; } /* Widen submit button in login forms */
> 
> ```

Thank you so much, Stephen! Using the code above, my login view gets extended across the full width of the page. Any idea what needs to be tweaked?

 ![Screenshot 2026-07-20 at 9.52.25 AM](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/8/8362b2ef89965eddb776e928274067c99405c22f.png)

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [July 20, 2026, 9:19pm UTC](https://forums.knack.com/t/centering-the-login/20483/4 "2026-07-20T21:19:38Z")

</div>

Hi @Joseph7, I’ve DM’ed you for further diagnosis.

---

<div class="post-metadata">

**Author:** ![Leah](https://avatars.discourse-cdn.com/v4/letter/l/c89c15/32.png) [@Leah](https://forums.knack.com/u/Leah)\
**Post date:** [July 21, 2026, 4:28pm UTC](https://forums.knack.com/t/centering-the-login/20483/5 "2026-07-21T16:28:32Z")

</div>

I’d love to know the “further diagnosis” also, what change is made so that the view is not full width?

---

<div class="post-metadata">

**Author:** ![Abdelghani42247](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@Abdelghani42247](https://forums.knack.com/u/Abdelghani42247)\
**Post date:** [July 21, 2026, 5:36pm UTC](https://forums.knack.com/t/centering-the-login/20483/6 "2026-07-21T17:36:01Z")

</div>

Try this, hope it will work:  
/\* LOGIN VIEW FORMATTING \*/  
.kn-scene:has(.kn-login),  
#knack-reset-pass {  
max-width: 420px;  
margin: 60px auto;  
padding: 0 20px;  
}

.kn-login-form {  
width: 100%;  
}

.kn-login .column,  
.kn-login .column.is-half,  
#knack-reset-pass .column,  
#knack-reset-pass .column.is-half {  
width: 100%;  
}

.kn-login .kn-button[type=“submit”],  
#knack-reset-pass .kn-button[type=“submit”] {  
width: 100%;  
}

---

<div class="post-metadata">

**Author:** ![Adrian\_vD](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@Adrian\_vD](https://forums.knack.com/u/Adrian_vD)\
**Post date:** [July 22, 2026, 4:42am UTC](https://forums.knack.com/t/centering-the-login/20483/7 "2026-07-22T04:42:55Z")

</div>

Was hoping to fix this one day also.

I noticed it is to do with whether your site is set to Full Width or Max Width. Max Width works like Stephen’s example. If in Full Width you get the extended one.

The problem I have is the logo on top of the login is not centering, and I am not programmy enough to figure that out.

---

<div class="post-metadata">

**Author:** ![LeighBerre96926](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/leighberre96926/32/4896_2.png) [@LeighBerre96926](https://forums.knack.com/u/LeighBerre96926)\
**Post date:** [July 22, 2026, 5:46am UTC](https://forums.knack.com/t/centering-the-login/20483/8 "2026-07-22T05:46:10Z")

</div>

Adrian, do you just have the logo as a picture in a rich text view? You should be able to just select it in the rich text view in the builder and use the alignment button to set it to center. It will create HTML that centers the content - in my case it looks like this in the builder:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/c/c73e0068b49f5a1560899264f5b5d46067ee741f.png)

and with appropriate CSS to center the login form like this in the live app:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/f/f244f217dcdb9ba0a3e70d04d441feb25ee772c5.png)

and the CSS I use to centre the login fields is:

```auto
/* LOGIN VIEW FORMATTING
---------------------------------------------------------- */
.kn-login, #knack-reset-pass {
  position: static !important;
  top: auto !important;
  left: auto !important;
  right: auto !important;
  bottom: auto !important;
  margin-left: auto !important;
  margin-right: auto !important;
  max-width: 400px !important;
  text-align: center;
}
.kn-login-form { max-width: 100%; }
.kn-login .column.is-half, #knack-reset-pass .column.is-half { width: 100%; }
.kn-login .kn-button[type="submit"], #knack-reset-pass .kn-button[type="submit"] { width: 100%; }

```

Its not perfectly centered, but I actually like the login fields and button being left justified so i havent wanted to change that,

---

<div class="post-metadata">

**Author:** ![Adrian\_vD](https://avatars.discourse-cdn.com/v4/letter/a/f08c70/32.png) [@Adrian\_vD](https://forums.knack.com/u/Adrian_vD)\
**Post date:** [July 22, 2026, 6:27am UTC](https://forums.knack.com/t/centering-the-login/20483/9 "2026-07-22T06:27:27Z")

</div>

The logo is the one used in the Design menu for the App, so is at the top of every page.

---

<div class="post-metadata">

**Author:** ![LeighBerre96926](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/leighberre96926/32/4896_2.png) [@LeighBerre96926](https://forums.knack.com/u/LeighBerre96926)\
**Post date:** [July 22, 2026, 6:49am UTC](https://forums.knack.com/t/centering-the-login/20483/10 "2026-07-22T06:49:05Z")

</div>

Ah, gotcha - you mean the one that is sitting top left hand corner. I dont know how to centre that - thats usually where my menu is …

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [July 22, 2026, 9:18pm UTC](https://forums.knack.com/t/centering-the-login/20483/11 "2026-07-22T21:18:36Z")

</div>

@Adrian_vD was correct about the max width, I overlooked that.  
I have updated my CSS snippet in the original response by including `!important` against the `max-width`, `margin-left` and `margin-right` attributes. This is now compatible with max width and full width apps.

@Adrian_vD, there is a native setting to center the logo if that helps?

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/3/357477e30d365e502028dbdcd1ea0865cb98a443.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/c/c3b2b0b047a618737f69a82e8b3290546a037e7e.png)

---

<div class="post-metadata">

**Author:** ![Joseph7](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Joseph7](https://forums.knack.com/u/Joseph7)\
**Post date:** [July 26, 2026, 11:32pm UTC](https://forums.knack.com/t/centering-the-login/20483/12 "2026-07-26T23:32:47Z")

</div>

Hooray! That update absolutely did the trick - and as a bonus, it centers the authenticator input as well. (Which previous codes snippets did not.) Thank you so much @StephenChapman. And thanks to everyone for the discussion!

---

<div class="post-metadata">

**Author:** ![LeighBerre96926](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/leighberre96926/32/4896_2.png) [@LeighBerre96926](https://forums.knack.com/u/LeighBerre96926)\
**Post date:** [July 27, 2026, 7:29am UTC](https://forums.knack.com/t/centering-the-login/20483/13 "2026-07-27T07:29:38Z")

</div>

Yes, great solution. In my app I have a logo above the login block, and in the case of a bad password the login block was redrawn over the top of the logo. So I took Steve’s code and extended it to deal with that logo properly - available in my edited post above. Now looks like this:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/8/8680c511934a46259d713bce6c82077b42d86c2a.png)

---

<div class="post-metadata">

**Author:** ![Leah](https://avatars.discourse-cdn.com/v4/letter/l/c89c15/32.png) [@Leah](https://forums.knack.com/u/Leah)\
**Post date:** [July 29, 2026, 6:47pm UTC](https://forums.knack.com/t/centering-the-login/20483/14 "2026-07-29T18:47:22Z")

</div>

Thank you! I had to use gemini to trouble shoot a few things but I got it working!
