A
A
Alena_Y2020-08-26 21:00:49
css
Alena_Y, 2020-08-26 21:00:49

How to change the width of a flex item when flex-wrap is activated?

Good day, there is a container, there are two flex elements in the container, the first has a width of 60%, the second is 40%
In order to adapt to mobile screens, the flex-wrap property was added so that at low resolutions the second element does not fit on another, but is transferred to another line
But there is a problem: when transferring the second element to another line, its width (40%) remains, and in case of transfer, I would like the second element to occupy the entire space (width by 100%)
I wanted to ask what js methods are for tracking the flex-wrap event, and is it possible to change the width of an element when wrapping to a new line using css?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hzzzzl, 2020-08-26
@Alena_Y

But there is a problem: when moving the second element to another line

roughly measure in pixels at what point it happens, and
@media (max-width: 600px) {  /*  при 600 рх */
  .element2 {  
    flex-basis: 100%;    /*   на всю ширину */ 
  }
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question