For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /note/css/scrollbar.md.

滚动条美化

浏览器全屏设置

CSS
html {
	// 兼容IE浏览器(可以省略)
	-ms-overflow-style: none;
	// 兼容Firefox浏览器(可以省略)
	overflow: -moz-scrollbars-none;
	// 主要代码
	overflow: hidden;
	overflow-y: scroll;
	scrollbar-width: none;
}
// 去除Chrome浏览器右侧滚动条区域的宽度
html::-webkit-scrollbar {
	width: 0 !important;
}

页面 Header 顶部固定设置

CSS
.header {
    width: 100%;
    position: fixed;
    z-index: 1;
}

Firefox 浏览器滚动条优化

Firefox 浏览器滚动条优化
/* 处理 Firefox 浏览器滚动条样式 */
* {
    scrollbar-width: thin;
    scrollbar-color: #b2b2b2 transparent;
    /* overflow-scroll: touch; */
    webkit-overflow-scrolling: touch;
}
/* 处理 chrome、edge 等浏览器滚动条 */
::-webkit-scrollbar {
    width: 4px;
    height: 5px;
}

::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.5);
}

::-webkit-scrollbar-track:hover {
    border-radius: 5px;
}

浏览器内容区占领剩余高度设置

CSS
.content {
    width: 100%;
    height: calc(100vh - {header高度 + footer高度}px);
}
注意事项

calc() 函数为 CSS3 中的一个方法属性,方便于动态计算模块的高度。