gpt4 book ai didi

css - 调整窗口大小时表格滚动条消失

转载 作者:行者123 更新时间:2023-11-28 18:57:14 25 4
gpt4 key购买 nike

我为电子商务网站的后台制作了一张 table 。表格内容 (tbody) 具有固定高度,并且可以通过右侧的滚动条滚动,如下图所示:http://img690.imageshack.us/img690/6483/screenshot20110917at819.png

问题是,如果我调整浏览器窗口的大小,这个表格滚动条就会消失:http://img26.imageshack.us/img26/4919/screenshot20110917at820.png

我知道这应该是正常行为,但我的客户坚持要保持表格滚动条,即使在调整窗口大小时也是如此。有没有办法实现这种行为?

引用css:(表体类为scrollContent)

/* define height and width of scrollable area. Add 16px to width for scrollbar */
div.tableContainer {
clear: both;
overflow: auto;
width: 100%;
}

/* set table header to a fixed position. WinIE 6.x only */
/* In WinIE 6.x, any element with a position property set to relative and is a child of */
/* an element that has an overflow property set, the relative value translates into fixed. */
/* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */
thead.fixedHeader tr {
position: relative
}

/* set THEAD element to have block level attributes. All other non-IE browsers */
/* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
html>body thead.fixedHeader tr {
display: block;
width: 100%
}

/* define the table content to be scrollable */
/* set TBODY element to have block level attributes. All other non-IE browsers */
/* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
/* induced side effect is that child TDs no longer accept width: auto */
html>body tbody.scrollContent {
display: block;
overflow-y: auto;
overflow-x: hidden;
width: 100%;
}

最佳答案

实际上,如果您更改 overflow-x: scroll 或 auto 应该可以解决问题。由于它是隐藏的,他们无法访问滚动条,这可能是他们的提示。

另一种选择是运行 javascript 或 jquery 来检查屏幕分辨率,然后用不同的表格替换表格或用较小的图像替换图像。这将允许表格缩小,以便它可以显示在非最大化窗口中。

/---- 编辑 ----/

检查窗口调整大小(您也不必在窗口上执行此操作,您可以在元素上执行此操作,但窗口会让您更准确地了解他们是否调整了窗口大小。

var timerID = 0,
var winWidth = $(window).width(),
var winHeight = $(window).height();

$(document).ready(function()
{
$(window).resize(function()
{
var winNewWidth = $(window).width(),
winNewHeight = $(window).height();
if(winWidth != winNewWidth || winHeight != winNewHeight)
{
window.clearTimeout(timerID);
timerID = window.setTimeout(function()
{
// do something here
},100)
}
winWidth = winNewWidth;
winHeight = winNewHeight
});
});

关于css - 调整窗口大小时表格滚动条消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7451366/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com