I have the following HTML:
<div class="wrapper">
<div class="container">
<div class="child">
1
</div>
<div class="child">
2
</div>
<div class="child">
3
</div>
<div class="child">
4
</div>
</div>
</div>
How do I make the .container expand it's width over the 100% of the parent width in order to accomodate all his children? The end goal is that I want to use Javascript to check if the child is wider than the parent, if yes I'll add arrows left and right to move the content left and right (it's a tabber).
Here's a fiddle, as you can see javascript sees the same width for both elements, but the child should be larger than the parent:
$(function() {
$("[data-w-width]").text($(".wrapper").width());
$("[data-c-width]").text($(".container").width());
})
* {
box-sizing: border-box;
}
html, body {
overflow: hidden;
}
.wrapper {
width: 100%;
}
.container {
width: auto;
display: flex;
}
.child {
width: 200px;
background: #dadada;
border: 1px solid black;
flex-shrink: 0;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrapper">
<div class="container">
<div class="child">
1
</div>
<div class="child">
2
</div>
<div class="child">
3
</div>
<div class="child">
4
</div>
</div>
</div>
<div>
wrapper width: <span data-w-width>0</span>
</div>
<div>
container width: <span data-c-width>0</span>
</div>