CSS div元素 - 如何显示水平滚动条? [英] CSS div element - how to show horizontal scroll bars only?

查看:306
本文介绍了CSS div元素 - 如何显示水平滚动条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个div容器,并已定义其样式如下:

I have a div container and have defined its style as follows:

div#tbl-container 
{
    width: 600px;   
    overflow: auto;    
    scrollbar-base-color:#ffeaff
}

水平和垂直滚动条,一旦我填充我的表,这是包含在这个div。
我只想让水平滚动条自动出现。我将以编程方式修改表的高度。

This gives me both horizontal and vertical scroll bars automatically once I populate my table which is contained by this div. I just want only horizontal scroll bars to appear automatically. I will modify the height of the table programmatically.

我如何做?

推荐答案

您不应同时获取水平和垂直滚动条,除非您将内容设置为足够大以满足其需要。

You shouldn't get both horizontal and vertical scrollbars unless you make the content large enough to require them.

但是,一个bug。

IE6-7(在其他浏览器中)支持所建议的CSS3扩展以独立设置滚动条,您可以使用它来抑制垂直滚动条:

IE6-7 (amongst other browsers) supports the proposed CSS3 extension to set scrollbars independently, which you could use to suppress the vertical scrollbar:

overflow: auto;
overflow-y: hidden;

您可能还需要为IE8添加:

You may also need to add for IE8:

-ms-overflow-y: hidden;

,因为Microsoft正在威胁将所有CR前标准属性移动到自己的在IE8标准模式。 (这将是有意义的,如果他们总是这样做,但现在对每个人都是一个不便。)

as Microsoft are threatening to move all pre-CR-standard properties into their own ‘-ms’ box in IE8 Standards Mode. (This would have made sense if they'd always done it that way, but is rather an inconvenience for everyone now.)

另一方面,它是完全可能的IE8将已修复错误。

On the other hand it's entirely possible IE8 will have fixed the bug anyway.

这篇关于CSS div元素 - 如何显示水平滚动条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆