如何在不向下转到页面的情况下显示水平滚动条

How to display horizontal scrollbar without go down to the page

本文关键字:情况下 显示 滚动条 水平      更新时间:2023-09-26

我有一个网页,其中包含垂直和水平列出的 100 多个数据。我有一个滚动条的 css 代码,如下所示:

.well {
overflow: auto;
}

用户始终需要向下滚动才能找到 horizotal 滚动条。有没有办法阻止它,这样用户就不需要一直向下找到他的滚动条?

如果你的数据在div的块元素中,并且你希望用户不需要一直向下找到他的滚动条,那么给它超链接" href="divid"。 当用户从任何链接登陆该页面时 http://exampl/#divid 它将自动登陆该div。

如果你的数据在 HTML 中的块元素中,你可以使用 css height 属性给它一个固定的高度。然后使用溢出-x属性添加水平滚动条。

.well {
   height: 200px;
   overflow-x: scroll;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
div { white-space: pre; }
section {
  max-height: 100%;
  overflow: auto;
}
<section>
<h1>Some content</h1>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
</section>
  
<section>
<h1>Some content</h1>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
<div>
Hi guys I have a webpage contains 100s of data listed vertically and horizontally. I have a css code for scroll bar as follows:
.well {
  overflow: auto;
}
User always need to scroll down to find the horizotal scroll bar. Is there anyway to prevent it, so that user dont need to go all the way down to find his scroll bar? Any idea guys? Thanks in advance.
</div>
</section>

您可以使用 overflow-x: 滚动 or overflow: 滚动

https://jsfiddle.net/h4bjLL0g/

body {
   overflow-x: scroll;
}
.well {
    height: 400px;
    overflow-x: scroll;
 }

您需要计算屏幕上的剩余空间,然后调整元素高度以适应它。下面是一个代码,它可能需要一些摆弄,但它在基本情况下工作。还要记住在调整大小事件时调用它,以适应这种情况:

const element = document.getElementById('specialElement');
const elementSize = element.getBoundingClientRect();
const elementStyle = window.getComputedStyle(element);
const windowHeightValue = window.innerHeight;
const elementHeight = windowHeightValue - elementSize.top - 2 * parseInt(elementStyle.marginTop, 0);
element.style.height = elementHeight + 'px';

元素父级必须启用水平滚动。元素应该是脱离图表的元素。