Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center login form in web page/browser using Antd?

Current output: login form

<Row type="flex" justify="center" align="center">
    <Col span={4} >
      <form onSubmit={handleSubmit(this.handleSubmit)} >
        <Field
          style={{ marginBottom: 12 }}
          prefix={<Icon type="user" style={{ color: 'rgba(0,0,0,.25)' }} />}
          name="name"
          type="text"
          component={AInput}
        />
        <Field
          style={{ marginBottom: 12 }}
          className="form-group"
          prefix={<Icon type="lock" style={{ color: 'rgba(0,0,0,.25)' }} />}
          name="password"
          type="password"
          component={AInput}
          />

          <Button

            block
            type="primary"
            htmlType="submit"
            className="login-form-button"
          >
            Log in
          </Button>
      </form>
    </Col>
  </Row>

above login form need to center in web page, i tried it using antd styling elements but failed. it would be using css inline styling but i do not want to this way.

like image 923
Muhammad Sulman Avatar asked Dec 27 '18 15:12

Muhammad Sulman


1 Answers

Make sure your row takes the whole page

<Row type="flex" justify="center" align="middle" style={{minHeight: '100vh'}}>

Output looks like this: Antd Example

like image 115
Tziortzis Kyprianou Avatar answered Oct 09 '22 06:10

Tziortzis Kyprianou