0

I want to hide scrollbar of cdk-virtual-scroll element but can't find a way. this is what i have done so far but its not working for firefox. working fine in chrome.

this is my css file

cdk-virtual-scroll-viewport::-webkit-scrollbar {
    width: 0px;/* remove scrollbar space */
    background: transparent;/* optional: just make scrollbar invisible */
}

 cdk-virtual-scroll-viewport {
   -ms-overflow-style: none !important; // IE 10+
    scrollbar-width: none !important;
    overflow: -moz-scrollbars-none !important;
  }

this is my html file

<cdk-virtual-scroll-viewport role="list" [itemSize]="95"><div *cdkVirtualFor="let site of sites;let i=index;let last = last;trackBy: trackByIdx" tabindex="{{i}}+1">
    <li class="mdc-list-item site-list-item" (click)="routeToSite(site)">
          <span class="mdc-list-item__text">
            <span class="mdc-list-item__primary-text">{{site.name | truncate:60:true }}</span>
            <span class="mdc-list-item__secondary-text">{{site.groupName}} - {{site.siteType.name }}</span>
            <span class="mdc-list-item__secondary-text">{{site.numOfUsers}} Users, {{site.numOfJsas }}
              JSAs</span>
          </span>
           </li>
       </div>
    </cdk-virtual-scroll-viewport>
Palak Jadav
  • 1,202
  • 1
  • 11
  • 23

2 Answers2

1

Just give

.class {
    scrollbar-width: none;
}
António Almeida
  • 9,620
  • 8
  • 59
  • 66
Pran R.V
  • 1,015
  • 12
  • 21
0

you just need to add browser prefix for mozilla browser -moz-scrollbar-width: none;

see demo below

ul{
  list-style-type: none;
  padding-left: 0;
  background-color: #f5f5f5;
  height: 50px;
  overflow: auto;
}
li{
  background-color: #ddd;
  display: block;
  margin: 2px 0;
}

ul::-webkit-scrollbar {
    width: 0px;/* remove scrollbar space */
    background: transparent;/* optional: just make scrollbar invisible */
}
ul {
   -ms-overflow-style: none; // IE 10+
    -moz-scrollbar-width: none;
    scrollbar-width: none;
    overflow: -moz-scrollbars-none;
  }
<ul>
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
</ul>

Note According to https://caniuse.com/#feat=css-scrollbar this will work for FF 64 and above

if you still want to use custom scrollbar then you should go with some jquery plugin

Rahul
  • 4,294
  • 1
  • 10
  • 12