cssreactjsant-design-pro

How to apply css to a specific placeholder in a form


I am working on a React project and for designing I am using Ant design framework. What I trying to do is I have form in that I have four Input tags, I need to add some changes for third Input tag, What I want to do is for third Input tag I am trying to give margin-left. But I don't know how to do it so someone help me how to resolve this.

This is my code App.js

import React from "react";
import 'antd/dist/antd.css';
import { Row, Col, Button, Form, Card, Input, DatePicker } from 'antd';
import { SearchOutlined, StopOutlined } from '@ant-design/icons';
import "./App.css";


const App = () => {
  return (
    <div>
      <Row>
<Col className="main" span={18}>
          <div className="customizedCards">
            <Card>
              <Col className="main" span={7}>
                <div className="main-form">
                  <h5 className="idDetails">ID DETAILS</h5>
                  <Form>
                    <Form.Item>
                      <Input className="firstInput common" placeholder="Name" />
                    </Form.Item>
                    <Form.Item>
                      <Input className="secondInput common" placeholder="ID Number" />
                    </Form.Item>
                    <Form.Item>
                      <DatePicker className="date" placeholder="Expiration Date" format="YYYY-MM-DD HH:mm:ss" />
                    </Form.Item>
                    <Form.Item>
                      <Input className="fourthInput common" placeholder="Issue Date" />
                    </Form.Item>
                  </Form>
                </div>
              </Col>
            </Card>
          </div>
        </Col>
      </Row>
 </div>
  )
}

export default App

This is App.css

.idDetails {
  font-weight: bold;
}

.common {
  padding-top: 5px;
  padding-bottom: 10px;
  border-radius: 4px;
}

.date {
  padding-left: 121px;
  padding-top: 5px;
  padding-bottom: 10px;
  border-radius: 4px;
}


````

Solution

  • just delete your .date selector and use this selector if you need right align

    .ant-picker-input > input {
      text-align: right;
    }