admin管理员组文章数量:1247209
I have structure of :
#navBar {
height: 55px;
width: 40px;
overflow-x:scroll;
overflow-y:hidden;
}
<div id="navBar">
akdhbaIDBhbfbhwhfbaibf
<div style="width: 80; float: left; text-align: center;">
<img src="http://192.168.2.105/SB_Site/icons/Home2.jpg" alt="Nav1" />
<br />
<span style="font-size: 80%">Nav1</span>
</div>
<div style=" width: 80; float: left; text-align: center;">
<img src="http://192.168.2.105/SB_Site/icons/Home2.jpg" alt="Nav2" />
<br />
<span style="font-size: 80%">Nav2</span>
</div>
<div style=" width: 80; float: left; text-align: center;">
<img src="http://192.168.2.105/SB_Site/icons/Home2.jpg" alt="Nav3" />
<br />
<span style="font-size: 80%">Nav3</span>
</div>
</div>
I want that all of the inner div
s will scroll-x
and not break the line. How can I achieve that?
I have structure of :
#navBar {
height: 55px;
width: 40px;
overflow-x:scroll;
overflow-y:hidden;
}
<div id="navBar">
akdhbaIDBhbfbhwhfbaibf
<div style="width: 80; float: left; text-align: center;">
<img src="http://192.168.2.105/SB_Site/icons/Home2.jpg" alt="Nav1" />
<br />
<span style="font-size: 80%">Nav1</span>
</div>
<div style=" width: 80; float: left; text-align: center;">
<img src="http://192.168.2.105/SB_Site/icons/Home2.jpg" alt="Nav2" />
<br />
<span style="font-size: 80%">Nav2</span>
</div>
<div style=" width: 80; float: left; text-align: center;">
<img src="http://192.168.2.105/SB_Site/icons/Home2.jpg" alt="Nav3" />
<br />
<span style="font-size: 80%">Nav3</span>
</div>
</div>
I want that all of the inner div
s will scroll-x
and not break the line. How can I achieve that?
- Hi,I need all the inner divs will be in one line. – the_farmer Commented Jul 21, 2012 at 6:49
3 Answers
Reset to default 10This will work:
<style type="text/css">
#navBar {
height: 55px;
width: 80px;
overflow-x: scroll;
overflow-y:hidden;
white-space: nowrap;
}
#navBar div {
display: inline-block;
}
</style>
and for HTML part:
<div id="navBar">
akdhbaIDBhbfbhwhfbaibf
<div style="width: 100px; text-align: center; background-color: red;">
<img src="" alt="Nav1" />
<br />
<span style="font-size: 80%">Nav1</span>
</div>
<div style=" width: 100px; text-align: center;">
<img src="" alt="Nav2" />
<br />
<span style="font-size: 80%">Nav2</span>
</div>
<div style=" width: 100px; text-align: center; background-color: red;">
<img src="" alt="Nav3" />
<br />
<span style="font-size: 80%">Nav3</span>
</div>
</div>
No need for float: left;
CSS.
Add white-space: nowrap
to the #navBar and display: inline-block;
to the inner divs. I believe that should do it.
Take a look at this fiddle: http://jsfiddle/fzLwX/1/
This might be what you're looking for:
#navBar div{
overflow-x:auto;
}
本文标签: javascriptforce inner elements to overflowxStack Overflow
版权声明:本文标题:javascript - force inner elements to overflow-x - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740276467a2253027.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论