When working with 'div' containers in CSS, you may encounter a situation where you desire horizontal scrollbars only. This article addresses how to achieve this behavior.
In the provided code snippet, you have configured the 'overflow' property to 'auto,' which allows both horizontal and vertical scrolling when the content exceeds the specified width or height. To restrict scrolling to the horizontal plane, modify the 'overflow-y' property as follows:
div#tbl-container { overflow: hidden; overflow-y: auto; scrollbar-base-color: #ffeaff; }
By setting 'overflow-y' to 'auto,' you allow automatic vertical scrolling if the content height exceeds the 'div' height, while 'overflow' being set to 'hidden' prevents horizontal scrolling unless the content width exceeds the specified 'div' width.
In Internet Explorer (IE) versions 6-7, an additional CSS3 extension is required for suppressing the vertical scrollbar:
div#tbl-container { overflow: auto; overflow-y: hidden; scrollbar-base-color: #ffeaff; -ms-overflow-y: hidden; }
This '-ms' prefix is employed to accommodate IE8 due to Microsoft's designation of pre-candidate recommendation standard properties under its own namespace.
It's noteworthy that IE8 may have addressed this bug, eliminating the need for the '-ms' prefix. Nevertheless, the CSS modifications mentioned above should provide the desired outcome in controlling scrollbars for 'div' elements.
The above is the detailed content of How to Control Horizontal Scrollbars in CSS 'div' Elements?. For more information, please follow other related articles on the PHP Chinese website!