Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!