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

186
Vistas
Size of divs in HTML

I want to reduce the size of these divs so that every row contain 3 cards at most. As I change the measurements in the CSS, it gets smaller and smaller. PS I'm not allowed to use Bootstrap! I tried using different measurements and also the grid feature but it was of no help.

This is the screenshot of the divs on my website

.locations .box-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  grid-template-rows: auto;
}

.locations .box-container .box {
  overflow: hidden;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.1);
  border: 1rem solid #fff;
  border-radius: 0.5rem;
  flex: 1 1 30rem;
  height: 25rem;
  position: relative;
}

.locations .box-container .box img {
  height: 100%;
  width: 100%;
  object-fit: cover;
}

.locations .box-container .box .card-body {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  text-align: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 2rem;
  padding-top: 5rem;
}

.locations .box-container .box .card-body .card-btn {
  display: inline-block;
  margin-top: 1rem;
  background: orange;
  color: #fff;
  padding: 0.8rem 3rem;
  border: 0.2rem solid orange;
  cursor: pointer;
  font-size: 1.7rem;
}

.locations .box-container .box .card-body .card-btn:hover {
  border: 2px solid orange;
  color: orange;
  background: transparent;
  transition: 0.4s ease;
}

.locations .box-container .box .card-body .card-btn:focus {
  outline: none;
}

.locations .box-container .box .card-body h5 {
  font-size: 2.5rem;
  color: orange;
}

.locations .box-container .box .card-body p {
  font-size: 1.5rem;
  color: #eee;
  padding: 0.5rem 0;
}
<section class="locations">
  <h1>Locations</h1>
  <p>"Adventure is out there."</p>
  <br>
  <div class="box-container">
    <div class="box">
      <div class="card">
        <img src="./murree.jpg" alt="Murree, Pakistan">
        <div class="card-body">
          <h5>Murree</h5>
          <p>Some quick example text to build on the card title and make up the bulk of the card's content.</p>
          <a href="#" class="card-btn">View</a>
        </div>
      </div>
    </div>
  </div>
</section>

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

0

I simplified your HTML and CSS a bit, but this solution should work. This will give you 3 cards per row, and will fill the rows below it. I removed some of your styling for brevity, so you'll need to add that back, but this should give you the structure you need.

.locations .box-container
{
  display: flex;
  flex-wrap: wrap;
}

.locations .box-container .box
{
  overflow: hidden;
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.1);
  border: 1rem solid #fff;
  border-radius: 0.5rem;
  height: 25rem;  
  flex: 1 0 25%;
  margin: 0.5rem;
  box-sizing: border-box;
}       

.locations .box-container .box .card
{  
  height: 100%;
  width: 100%;
  text-align: center;
  background: rgba(0, 0, 0, 0.7);
  padding: 2rem;  
}
        
.locations .box-container .card h5
{
  font-size: 2.5rem;
  color: orange;
}

.locations .box-container .card p
{
  font-size: 1.5rem;
  color: #eee;
  padding: 0.5rem 0;
}

.locations .box-container .card a
{
  display: inline-block;
  margin-top: 1rem;
  background: orange;
  color: #fff;
  padding: 0.8rem 3rem;
  border: 0.2rem solid orange;
  cursor: pointer;
  font-size: 1.7rem;
}
<section class="locations">
  <div class="box-container">
  <div class="box">
    <div class="card">
      <h5>Title</h5>
      <p>Card content.</p>
      <a href="#">View</a>
    </div>
  </div>
  <div class="box">
    <div class="card">
      <h5>Title</h5>
      <p>Card content.</p>
      <a href="#">View</a>
    </div>
  </div>
  <div class="box">
    <div class="card">
      <h5>Title</h5>
      <p>Card content.</p>
      <a href="#">View</a>
    </div>
  </div>
    <div class="box">
    <div class="card">
      <h5>Title</h5>
      <p>Card content.</p>
      <a href="#">View</a>
    </div>
  </div>
    <div class="box">
    <div class="card">
      <h5>Title</h5>
      <p>Card content.</p>
      <a href="#">View</a>
    </div>
  </div>
  </div>
</section>

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