简体   繁体   中英

CSS add display block all items except some items

在此处输入图像描述

I have this div where I'm displaying some images, Can I add display: none to all items except first, second, and third?

  <ng-template #customDayTemplateHover let-day="day" class="cal-time-events">
<div class="user-day-off-template" *ngFor="let dayOff of dayOffsArrayDayView">
  <div class="users">
    <img class="user-img" src="{{dayOff.photo}}" alt="">
    <div class="name-type">
      <span class="type">{{dayOff.type}}</span>
      <span class="name">{{dayOff.employee_name}}</span>
    </div>
  </div>
</div>

You can use functional notation with the nth-of-type selector to do this.

For example:

ul li:nth-of-type(1n+4) { display: none; }

you can add attribute class to define a property css: https://www.w3schools.com/html/html_classes.asp

You can do a validate to know in what element going was this class

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM