css - 如何隐藏 Angular 组件中的默认浏览器滚动条?
问题描述
我想出了如何在 Angular 应用程序中全局隐藏滚动条,但我在实际项目中遇到了一个场景,我需要在单个 Angular 组件中隐藏默认滚动条,但在其他组件中可以看到默认滚动条。::host 似乎没有解决这个问题。如果有人知道如何解决这个问题,我将非常感谢您的反馈!另外,如果可能的话,我会喜欢 CSS 解决方案,因为我觉得不应该有任何疯狂的解决方案或黑客来解决这个问题。我在下面做了一个快速的stackblitz...
https://stackblitz.com/edit/angular-ivy-syr7do?file=src/styles.css
解决方案
用这个
*::-webkit-scrollbar {
width: 0px !important;
background-color: white !important;
}
*::-webkit-scrollbar-thumb {
width: 0px !important;
background-color: whitesmoke !important;
border-radius: 0px !important;
}
*::-webkit-scrollbar:horizontal {
width: 0px !important;
background-color: white !important;
}
*::-webkit-scrollbar-thumb:horizontal {
width: 0px !important;
background-color: whitesmoke !important;
border-radius: 0px;
}
*
如果需要,请替换为特定的类/ID。
不要忘记添加overflow:auto
推荐阅读
- mysql - 是否有一个 SQL 查询,它只能检索那些在第二个字母后包含连字符的数据?
- python - Twisted installation issue post visual studio update to 15.0
- sql - Data Truncation issue while importing excel from Azure Blob storage to Sql Server
- android - 使用导航架构停止重新加载上一个片段
- image-processing - 在 Chainer 模型中仅提供图像
- c# - 如何在具有一些不同位置 Unity 的模式中生成彼此向下的平台
- php - 编码 JSON (PHP) 中不带 /r /n 和 /t 的多行回显
- c# - 带有控制台工具的 DLL
- c++ - 如何创建具有固定列长和动态行长的二维向量?
- c# - 当我们在服务器上删除 http 标头时,我们收到错误,因为在这种情况下响应不可用