Consider the following snippet:
.page-wrapper {
border: 2px solid blue;
padding: 5px;
width: 700px;
/* I'm using flexbox here */
display: flex;
justify-content: center;
}
.container {
border: 5px solid red;
padding: 10px;
/*
Changing overflow-x, the box width will change:
hidden --> width is 700px
visible --> width is 3000px
*/
overflow-x: hidden;
}
.content {
background-color: orange;
width: 3000px;
height: 100px;
}
<div class="page-wrapper">
<div class="container">
<div class="content">
</div>
</div>
</div>
With overflow-x: hidden
:
With overflow-x: visible
:
Why changing the overflow-x
property on the container element, the container box's width changes?