Home > Back-end >  React.js, HTML, CSS: can't figure out why align-items doesn't work
React.js, HTML, CSS: can't figure out why align-items doesn't work

Time:12-28

I know this kind of question is asked a lot, but I haven't solve my problem despite trying many of suggested answers on other people's questions.

I am trying to center horizontally some <input /> in a div container, using styled-components, but I can't figure out why align-items doesn't work (even in the Chrome developer tool where you can tick/choose different CSS options for your style).

In my <FormBox /> (which is a styled div), I would like to align all the <FormInput /> (which are styled input`).

You can find an image with the problem here: Not_aligned_form

Here is my code :

import { useForm } from "react-hook-form"
import styled from 'styled-components'
import colors from '../../utils/style/colors'

const FormInput = styled.input`
    width: 400px;
    height: 40px;
    background: #FFFFFF;
    box-sizing: border-box;
    border: solid 0.4px ${colors.primary};
    box-shadow: 0px 4px 4px #5843E4;
    border-radius: 10px;    
    margin-top: 20px;   
    text-align: left;
    padding: 10px;
`
const SignupWrapper = styled.div`
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border: solid 1px;
  height: 100%;
`
const FormBox = styled.div`
    display:flex;
    flex-direction: column;
    justify-content: flex-start;
    align-content:center;
    align-items: center;
    width: 450px;
    height: 500px;
    border: solid 0.4px ${colors.primary};
    position: relative;
    margin: 0 auto;
    border-radius: 10px;
`

function Signup() { 

    const { register, handleSubmit, formState: { errors } } = useForm();
    const onSubmit = data => console.log(data);

    return(
        <SignupWrapper>
            <h1>Sign up            
  • Related