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

233
Visualizações
React element not expanding correctly in CSS Flex container

I am attempting to utilize the IBM Gantt Chart Component in a React application. The goal is to get the gantt chart component to span the entire page as seen below: enter image description here

In my JS source code, I have the following line:

          return(
            <div id="ganttDiv">
              <GanttChart config={config} />
            </div>
          );

In my CSS, I set the width to 100% and the height to 100vh. I also put thick borders to determine the extents of the div.

#ganttDiv{
    width: 100%;
    height: 100vh;
    border-color: rgb(102, 255, 0);
    border-style: dashed;
    border-width: 15px;
    background-color: rgb(255, 255, 255);
}

Instead of the React element spanning the entire page, I get: enter image description here

As you can see, the div correctly fills the entire page as shown with the green borders, but the contents of the div don't expand to fill the space.

After researching and looking around for several hours, I learned that I could use flex boxes.

Therefore, I added display: flex; to my CSS, and now the height looks correct: enter image description here

Unfortunately, the width now shrinks to less than half of the page instead of being 100% width from before.

I tried following the examples provided by MDN Web Docs and tried setting the CSS to row, row-reverse, column, and column-reverse which does not work.

It seems like I can only get it to span the entire width or span the entire height, but not both.

I hope that someone can help. Have a nice day. :-)

Edit: When I compile it with using 100vw as the others suggested, it doesn't do anything. However, if I edit with F12 developer tools the imported component itself (not the div), it works. On the sidebar, it says that the component is only inheriting color from the div, nothing else. So what should I do? enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

To fix the problem, it was necessary to apply the width to the component itself, not the div. Unfortunately, the syntax for doing this with React is different since we use JSX instead of HTML.

Therefore, to the fix the problem I had to do:

          return(
            <div id="ganttDiv" >
              <GanttChart config={config} style={{width: '100vw'}} />
            </div>
          );
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