Home>

I am creating an inquiry form
I want to arrange each item side by side
I used "flex box".

However, the "email address" part is
It will be different from other items.

"Company name"-"Telephone number"
"Required" for each item
If I want to align up and down
What should I do?

<section>
      <form action = "" method = "POST">
            
                        
                          <label for = "i_company">
                            Company name</label>
                        
                        
                          <em>Required</em>
                        
                        
                          <input type = "text" name = "company" required>
                        
            
            
                
                  <label for = "i_name">
                        Your name</label>
                
                    
                      <em>Required</em>
                    
                    
                      <input type = "text" name = "name" required>
                    
            
            
                
                  <label for = "i_mailadrees">
                        Email address</label>
                
                
                  <em>Required</em>
                
                
              <input type = "text" name = "mailadrees" required>
                
            
            
                
                  <label for = "i_telnumber">
                        Phone number</label>
                
                
                  <em>Required</em>
                
                
                  <input type = "text" name = "telnumber" required>
                
          

CSS

.container {
    border-top: 1px solid #ddd;
  padding-top: 24px;
  padding-bottom: 24px;
  width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.container label {
    width: 100%;
  max-width: 248px;
  letter-spacing: 0.05em;
  font-weight: bold;
    font-size: 18px;
}
.container em {
    border-radius: 6px;
    margin-right: 8px;
    margin-left: 40px;
  padding-top: 8px;
  padding-bottom: 8px;
  width: 48px;
  display: inline-block;
  text-align: center;
  background: # 5bc8ac;
  color: #fff;
  font-size: 14px;
}
.container input {
    border: 1px solid #ddd;
  border-radius: 6px;
  margin-left: 40px;
  padding-left: 1em;
    padding-right: 6em;
    padding-bottom: 30px;
  height: 30px;
  flex: 1;
  width: 100%;
  max-width: 410px;
  background: # eaedf2;
  font-size: 18px;
  • Answer # 1

    For example,
    CSS

    .container div: first-of-type {
        width: 150px;
    }


    I think it will be.

    How is it?

  • Answer # 2

    I think it's better to unify the width of the label, so
    ↓ Is it like this?

    .container>div: nth-child (1) {
        width: 15%;
        min-width: 10em;
    }