Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

234
Visualizações
Not able to align divs' inside a parent div in react

Here is the picture. I want to align the div's (with blue border) from top. I just want the CSS code for this. I tried to use margin but its not working. Also when more content is inserted inside these div's they expand from bottom to top, seems like bottom for these div's is fixed or something.

what I want is that the Inner div's (with blue border) should be top aligned not bottom aligned and when more text is added inside these div's it should expand from top top to bottom.

here.

enter image description here

here is the CSS code. propertiesContainer class is the parent div with red border and properties class are the inner div's

propertiesContainer: {
  paddingTop: "26px",
  background: " #EAEAFA",
  border: "1px solid red",
  opacity: 1,
},
properties: {
  bottom: "100px",
  margin: "19px",
  width: "auto",
  border: "2px solid blue",
  height: "262px",
},

Reactjs code for this

<section className={classes.propertiesContainer}>
  <HorizontalScroll
    itemClass="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12"
    data={
      mobile_footer_data &&
      mobile_footer_data.map((data, index) => {
        const { header, body } = data;
        console.log("dataa", data);

        const text = body.map((item, index) => {
          return <div key={index}>{item}</div>;
        });

        return (
          <div key={index} className={classes.properties}>
            <CommonHeaderText
              text={<span>{header}</span>}
              variant="h1"
              style={{
                fontSize: "16px",
                fontWeight: "bold",
                fontFamily: "Open Sans",
                color: "##363636",
                height: "19px",
                marginBottom: "25px",
              }}
            />

            <div>{text}</div>
          </div>
        );
      })
    }
  />
</section>;
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

For inline element, The default value of vertical-align is baseline. So, they are text baseline aligned. Trying applying this to the child div:

vertical-align: top;

        .outter {
            outline: 2px dashed #387779;
            padding: 10px;
        }

        .inner {
            width: 100px;
            height: 80px;
            display: inline-block;
            background-color: #a3af92;
            color: #26310a;
        }
        .vtop {
            vertical-align: top;
        }
    <div class="outter">
        <div class="inner">hello<br/>world<br/>abc</div>
        <div class="inner">abcd<br/>two</div>
        <div class="inner">123</div>
    </div>
    <br/>
    <div class="outter">
        <div class="inner vtop">hello<br/>world<br/>abc</div>
        <div class="inner vtop">abcd<br/>two</div>
        <div class="inner">123</div>
    </div>

about 4 years ago · Juan Pablo Isaza Relatório

0

suppose your parent div has className "parent" and it has two children "child1" and "child2" so the css will look like this

.parent{
   display:flex;
   justify-content:space-between;
   align-items:flex-start;
}

Trying applying this to the parent div , hope this solves your issue .

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda