CSS Properties: How to the second flex-item shrink three times more than the rest?
Solution:
HTML Code:
Explanation:
- This HTML document demonstrates how to make the second flex-item shrink three times more than the rest using CSS.
- Comments are added to both HTML and CSS to explain each section of the code.
- The CSS <style> block sets up flexbox layout for the container with id "w3r" and its child div elements.
- Each div element inside the container is assigned flex properties (flex-grow, flex-shrink, flex-basis) to control its flexibility within the flex container.
- The second div element is specifically targeted and given a higher flex-shrink value of 3, making it shrink three times more than the other div elements when necessary.
- This setup demonstrates how the flex-shrink property can be used to control the shrinkage behavior of flexible items within a flex container.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | No |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.