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

140
Visualizações
Make two divs be resizable at the same time inside a map

I have an array named products, that has 4 different products. By mapping it, I created 4 different resizable divs, like this:

 {products.map((item, index) => {
                return (
                  <div key={index} style={{ margin: "8px 0px 0px 0px", display: "flex" }}>
                    <div className="resizable-switch-column"> 
                        <div className="switch-container">
                          <div className="switch-bar"/>
                          </div>
                      </div>
                  </div>
                );
              })}

My question is:, how can I resize all of those divs at the same time? If I resize the second one, for example, all the other 3 divs must be resized at once.

Here is my CSS code:

.switch-container {
  background-color: var(--background-secondary);
  border-radius: 4px;
  height: 16px;
  margin: auto 0px;
  width: 100%;
}

.switch-bar{
  background-color: var(--color-primary-chrome20);
  border: 1px var(--color-primary-lighten2) solid;
  border-radius: 4px;
  max-width: calc(100% - 1px);
  overflow: auto;
  height: 14px;
  resize: horizontal;
}

.switch-bar::-webkit-resizer {
  background-color: transparent;
}

This is how it works at the moment.

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

0

Maybe you can store the width inline with the useState hook.

const [width, setWidth] = useState('100%');

<div style={{width: width}} yourDraggingFunction={() => whenDragging()} />

const whenDragging = () => setWidth(someWidthVariable);

Think of this as more pseudo code and don't take it so literally. The goal is to manipulate a single state variable regardless of the which element you resize.

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