【问题标题】:How to hide scrollbar in a div [duplicate]如何在div中隐藏滚动条[重复]
【发布时间】:2017-05-29 18:50:09
【问题描述】:

我制作了一个 div,它包含了可滚动的溢出内容,但我希望隐藏它的滚动,但 div 仍然可以滚动。

.description
{
    height: 150px;
    overflow: scroll;
}

<div class="description">
    <h4>Description</h4>
    <p>After a series of deadly discoveries, Bruce Wayne has learned that the Court of Owls is real � and a deadly threat out to control Gotham City! Unleashing their deadly assassins known as the Talons, Batman must stop the insidious Court of Owls before they claim the city for their own. In doing so, The Dark Knight will uncover dark secrets � not just about the city he�s sworn to protect, but about the history of the Wayne family.After a series of deadly discoveries, Bruce Wayne has learned that the Court of Owls is real � and a deadly threat out to control Gotham City! Unleashing their deadly assassins known as the Talons, Batman must stop the insidious Court of Owls before they claim the city for their own. In doing so, The Dark Knight will uncover dark secrets � not just about the city he�s sworn to protect, but about the history of the Wayne family.After a series of deadly discoveries, Bruce Wayne has learned that the Court of Owls is real � and a deadly threat out to control Gotham City! Unleashing their deadly assassins known as the Talons, Batman must stop the insidious Court of Owls before they claim the city for their own. In doing so, The Dark Knight will uncover dark secrets � not just about the city he�s sworn to protect, but about the history of the Wayne family.</p>
</div>

【问题讨论】:

标签: html css


【解决方案1】:

您可以通过应用适用于所有不同浏览器的 3 行 CSS 来隐藏滚动条。试试下面的 CSS[更新]

CSS:

.classname {
  height: 150px;
  overflow: scroll;
  -ms-overflow-style: none;
  /* for Internet Explorer, Edge */
  scrollbar-width: none;
  /* for Firefox */
}

.classname::-webkit-scrollbar {
  display: none;
  /* for Chrome, Safari, and Opera */
}

JSFiddle : https://jsfiddle.net/xet3r59k/3/

【讨论】:

  • 你能告诉我在 MOZILLA 或 IE 等其他浏览器中同样可以正常工作吗?
  • 你试过this吗?
  • 这不适用于除 chrome 之外的任何其他浏览器
猜你喜欢
  • 2015-03-16
  • 2016-03-26
  • 1970-01-01
  • 2014-11-17
  • 2013-12-17
  • 2014-09-25
  • 2014-06-11
  • 2019-01-28
  • 2021-01-27
相关资源
最近更新 更多