隐藏滚动条方法,网上找到的内容大多拷贝,粘贴,很多无效,这里给出2020年可用的隐藏滚动条办法,包括横向和纵向,chrome亲测有效。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>单行居中 多行靠左</title>
</head>
<style>
.container {
-ms-overflow-style: none; /* Internet Explorer 10+ */
scrollbar-width: none; /* Firefox */
}
.container::-webkit-scrollbar {
display: none; /* Safari and Chrome */
}
</style>
<body style="overflow: hidden">
<div class="container" style="width: 300px; background-color: #da8ec5;
overflow-x: scroll; white-space: nowrap;">
横向:我是滚动显示的文字,这里有隐藏的滚动条,我的后面还有很多内容
</div>
<p></p>
<div class="container" style="width: 100px; height: 50px; background-color: #da8ec5;
overflow-y: scroll;">
白日依山尽,黄河入海流。欲穷千里目,更上一层楼。
</div>
</body>
</html>