When I used Flexbox, I thought that width: 200%
would make an item twice the size of Flexbox, but it was wrong.Please tell me why this is happening, thank you.
<div style='width:50vw;margin:0 auto;display:flex;justify-content:center;align-items:center;border:1px solid black;'>
<div style='border:1px solid black;width:150%;
height:100%;overflow:auto;'>
<p> ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.
</p>
</div>
</div>
The flex item has the flex-shrink
property and the default value is 1. The flex-shrink
property is a factor that indicates how much the flex item shrinks to other flex items.
<'flex-shrink'>
This <number[0, ]]>
component sets flex-shrink
longhand and specifications the flex shrink factor, which determines how much the flex item will shrink relative to the rest of the flex items in the flexible containment is present.
This reduces the size of the flex item to the container size, so the flex item does not stick out.Therefore, setting the value of the flex-shirink
property to 0 solves this problem.
.container{
width —50vw;
margin:0 auto;
display:flex;
justify-content:center;
align-items:center;
border —1px solid black;
}
.item{
border —1px solid red;
width: 150%;
height —100%;
overflow —auto;
flex-shrink:0; /* Add */
}
<div class="container">
<div class="item">
<p> ahhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh.
</div>
</div>
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
618 Uncaught (inpromise) Error on Electron: An object could not be cloned
612 GDB gets version error when attempting to debug with the Presense SDK (IDE)
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.