Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
putting specifc number of element in a row in html/css

I have one application. form data is coming from backend. sometimes element can be 10 sometimes 3 sometimes 5. I need to put exactly 3 element in a row. if there are more than 3 they should be in next row. How can I achieve this using html/css or bootstrap.

In below example there are 7 elements. so there should be 3 row. in first 2 row there should be 3 element and in last row exactly 1. how can achieve this?

Below is the code. how can I inject the css on same.

 return (
      <div>
        <FormValidator emitter={this.emitter} />
        <div className='react-form-builder-form'>
          <form encType='multipart/form-data' action={this.props.form_action} method={this.props.form_method}>
            { this.props.authenticity_token &&
              <div style={formTokenStyle}>
                <input name='utf8' type='hidden' value='&#x2713;' />
                <input name='authenticity_token' type='hidden' value={this.props.authenticity_token} />
                <input name='task_id' type='hidden' value={this.props.task_id} />
              </div>
            }
            {items}
          </form>
          <div>
            {validationList}
          </div>
        </div>
      </div>
    )
  }

enter image description here

when I applied

   .form__container {
      display: flex;
      flex-wrap: wrap;
    }
    
    .form__container input {
      width: 33.33%;
    }



<div className='form__container'>
          <form encType='multipart/form-data' action={this.props.form_action} method={this.props.form_method}>
            { this.props.authenticity_token &&
              <div style={formTokenStyle}>
                <input name='utf8' type='hidden' value='&#x2713;' />
                <input name='authenticity_token' type='hidden' value={this.props.authenticity_token} />
                <input name='task_id' type='hidden' value={this.props.task_id} />
              </div>
            }
            {items}
          </form>
          <div>

it is coming like below.

enter image description here

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can use flex box to achieve this.

you can apply css in this manner to Outer and Inner elements:

.outer-container { display: flex; }
.inner-element { width: 33.33% }

In your case outer element will be the form container and inner element will be the input elements.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You have to add these styles to the parent of form inputs.

.form__container {
   display: flex;
   flex-wrap: wrap;
}

and assign a width to your input field.

.form__container input {
   width: 33.33%;
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

You could try using bootstrap with the grid system, using a container div with a row class, with several elements justify alignment and have divs with the col-4 class each, by mapping your array, in this case items, and returning this jsx to populate your data in rows of 3 elements that will be fairly distributed in the existing area of your items rendering section. Let me provide with a quick example of the mapping of this bootStrap approach. Hope this helps!

<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">      
<div>
   <FormValidator emitter={this.emitter} />
   <div className='react-form-builder-form'>
      <form encType='multipart/form-data' action={this.props.form_action} method={this.props.form_method}>
         { this.props.authenticity_token &&
         <div style={formTokenStyle}>
            <input name='utf8' type='hidden' value='&#x2713;' />
            <input name='authenticity_token' type='hidden' value={this.props.authenticity_token} />
            <input name='task_id' type='hidden' value={this.props.task_id} />
         </div>}
         <div className="container-fluid">
            <div className="row justify-content-between align-items-center">
            {items.map((item, ind) =>(  
            <div key={ind} className="col-4">
               <label htmlFor="exampleFormControlInput1" className="form-label">items.label</label>
               <input type="email" className="form-control" id="exampleFormControlInput1" placeholder="Lorem" />
            </div>
            ));}
         </div>
   </div>
   </>
   </form>
   <div>
      {validationList}
   </div>
</div>
</div> 
      <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda