I met a strange question, I set a div with style:
overflow-x: scroll
But the result is it doesn't overflow, just begin from a new line, my source code is as below:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>test</title>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1">
<style>
.fl {
float: left;
}
.cp-header {
height: 40px;
padding: 7px 0px;
border-bottom: 2px solid #cdcdcd;
box-sizing: border-box;
}
.cp-header span {
display: inline-block;
border-right: 2px solid #cdcdcd;
box-sizing: border-box;
text-align: center;
height: 24px;
line-height: 24px;
font-size: 14px;
}
</style>
</head>
<body>
<div style="width: 30%; box-sizing: border-box" class="fl">
<div class="cp-header" style="width:100%;">
<span style="width:100%;">name</span>
</div>
</div>
<div id="tabGrp" style="width: 70%; box-sizing: border-box;" class="fl">
<div class="cp-header" style="display: inline-block; overflow-x: scroll; white-space: nowrap;">
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
<span class="fl" style="width: 100px;">
tab
</span>
</div>
</div>
</body>
</html>
As you can see from above, I wish content in "#tabGrp" can be horizontally scroll, for I have set the property overflow-x:scroll, if its child elements' width exceeds their parent's width, the parent should scroll, however it doesn't work, anything wrong with me?
overflow-x: scroll;to.cp-headerand not#tabGrp