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

209
Views
How to only make the middle flex component responsive?

I have a parent component who has three child components. The display is set to flex and flex-direction to row.

here is the code

JS part:

<div className='Container'>
    <div className='Text1'>26 Dec 22</div>
    <div className='Text2'>Lorem ipsum dolor sit amet</div>
    <div className='Text3'>128K</div>
</div>

CSS part:

.Container{
    display: flex;
    flex-direction: row;
    background-color: white;
    padding: 20px 20px 20px 20px;
    justify-content: space-evenly;
    gap:10px;
}

.Text1{
    width: 100px;
    white-space: nowrap; 
}
.Text2{
    text-align: left;
    width: 400px;
}
.Text3{
    width: 100px;
}

Here is the image of the output: enter image description here

When I change from desktop view to mobile view I want my result to be like this enter image description here

As one can see only the middle component text was eliminated and ... was added.

In my above code when I change the view I get the result as

enter image description here

Please guide me on how to decrease the width of only the middle component and also add ... when part of the middle component disappears.

about 4 years ago · Santiago Gelvez
1 answers
Answer question

0

In your case, you need the text-overflow: ellipsis; CSS property and use it on the middle element.

The text-overflow CSS property sets how hidden overflow content is signaled to users. It can be clipped, display an ellipsis ('…'), or display a custom string. MDN documentation

.Container {
  display: flex;
  flex-direction: row;
  background-color: white;
  padding: 20px 20px 20px 20px;
  justify-content: space-evenly;
  gap: 10px;
}

.Text1 {
  width: 100px;
  white-space: nowrap;
}

.Text2 {
  text-align: left;
  width: 400px;
  text-overflow: ellipsis; /* new line */
  overflow: hidden; /* new line */
  white-space: nowrap; /* new line */
}

.Text3 {
  width: 100px;
}
<div class="Container">
  <div class="Text1">26 Dec 22</div>
  <div class="Text2">Lorem ipsum dolor sit amet</div>
  <div class="Text3">128K</div>
</div>

about 4 years ago · Santiago Gelvez 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!