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

300
Vistas
flexbox - how to make 2 flex-item have same width

I want 2 flex-item have the same width, no matter what is the width of the content.

After I set flex: 1 1 0; on flex-item, it still not works as expected
because I expect the width of ME will be same as Everyone

enter image description here

App.js

import React from 'react'

import "./style.css";

function Tab() {
    return (
        <div className="tab">   
            <div className="tab__item">Me</div>
            <div className="tab__item">Everyone</div>
        </div>
    )
}

export default Tab

style.css

.tab {
  display: flex;
}
.tab .tab__item {
  flex: 1 1 0; // not working
  border: 1px solid #c3c4c7;
  padding: 0.1rem 0.2rem;
}
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

It might be related to your other styles somewhere else but you could try this

    function App() {
    return (
        <div className="tab">   
            <div className="tab__item">Me</div>
            <div className="tab__item">Everyone</div>
        </div>
    )
    }

    const rootElement = document.getElementById("root");
    ReactDOM.render(<App />, rootElement);
.tab {
  display: flex;
}
.tab .tab__item {
  width: 100%;
  border: 1px solid #c3c4c7;
  padding: 0.1rem 0.2rem;
}
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js"></script>
    <div id="root"></div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

Maybe this?

.tab .tab__item {
  flex-basis: 50%;
  border: 1px solid #c3c4c7;
  padding: 0.1rem 0.2rem;
}
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