代码之家  ›  专栏  ›  技术社区  ›  CPK_2011

需要有角度的材料下拉面板才能有向下和向上箭头按钮

  •  0
  • CPK_2011  · 技术社区  · 10 月前

    我正在使用 Angular 15 , Angular Material 14 CSS

    我几乎已经完成了这个样品的工作。。

    我正在使用 -webkit-scrollbar 从此链接- Orangeable Scrollbars

    使用的代码如下。。。

    <mat-select disableOptionCentering (selectionChange)="validateInputs(userForm)" formControlName="siteId" placeholder="Select Site ID" panelClass="custom-panel-siteId">
    
    .custom-panel-siteId {
      margin: 40px 0px !important;
      min-width: 313px !important;
      margin-left: 17px !important;
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar {
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-track {
      border-radius: 5px;
      background-color: rgba(242, 242, 242);
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb {
      border-radius: 5px;
      background-color: rgba(211, 211, 211);
    }
    

    输出是这样的。。。

    我只需要补充一下 Down Up 滚动条的箭头。

    我怎样才能做到这一点?

    Scrollbar

    2 回复  |  直到 10 月前
        1
  •  1
  •   Naren Murali    10 月前

    看完这个 codepen 我终于找到了合适的滚动条来解决这个问题!

    css

    .custom-panel-siteId {
      margin: 40px 0px !important;
      min-width: 313px !important;
      margin-left: 17px !important;
      border-radius: 5px !important;
    }
    
    .custom-panel-siteId::-webkit-scrollbar {
      width: 20px;
      height: 12px;
      background-color: #f1f1f1;
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb {
      border-radius: 1px;
      background-color: #c1c1c1;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:hover {
      background-color: #a8a8a8;
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:horizontal {
      border-top: 2px solid #f1f1f1;
      border-bottom: 2px solid #f1f1f1;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:vertical {
      border-left: 2px solid #f1f1f1;
      border-right: 2px solid #f1f1f1;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-thumb:active {
      background-color: #787878;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-track-piece {
    }
    
    .custom-panel-siteId::-webkit-scrollbar-track {
      background-color: #f1f1f1;
      border-radius: 5px;
    }
    
    /* Buttons */
    .custom-panel-siteId::-webkit-scrollbar-button {
      background-color: #f1f1f1;
      background-repeat: no-repeat;
      background-size: 7px;
      background-position: center;
      height: 17px;
      width: 17px;
      border-radius: 5px;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:disabled {
      /* Why is this not red??? */
      background-color: red;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:hover {
      background-color: #d2d2d2;
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:active {
      background-color: #787878;
    }
    
    /* Up */
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:decrement {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='50,30 100,80 0,80'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:decrement:active {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23FFFFFF'><polygon points='50,30 100,80 0,80'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:decrement:hover {
      border-color: transparent transparent #505050 transparent;
    }
    
    /* Down */
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:increment {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='0,15 100,15 50,75'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:vertical:increment:hover {
      border-color: #505050 transparent transparent transparent;
    }
    
    /* Left */
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:decrement {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='15,50 75,100 75,0'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:decrement:hover {
      border-color: transparent #505050 transparent transparent;
    }
    
    /* Right */
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:increment {
      background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='100' height='100' fill='%23505050'><polygon points='15,0 15,100 75,50'/></svg>");
    }
    
    .custom-panel-siteId::-webkit-scrollbar-button:horizontal:increment:hover {
      border-color: transparent transparent transparent #505050;
    }
    

    stackblitz

        2
  •  0
  •   codewithharshad    10 月前

    HTML

    <mat-select
            name="countryString"
            [(value)]="selectedCountry"
            placeholder="Country"
          >
            <mat-option *ngFor="let data of countries" [value]="data.full">{{
              data.full
            }}</mat-option>
          </mat-select>
    

    TS

    export class AppComponent {
      constructor() {}
    
      countries: any = [
        {
          full: 'Great Britain',
          short: 'GB',
        },
        {
          full: 'United States',
          short: 'US',
        },
        {
          full: 'Canada',
          short: 'CA',
        },
        {
          full: 'asas',
          short: 'GB',
        },
        {
          full: 'United States',
          short: 'US',
        },
        {
          full: 'Canada',
          short: 'CA',
        },
      ];
      selectedCountry: string = 'GB';
    
      selectedCountryControl = new FormControl(this.selectedCountry);
    }
    

    默认情况下,垫子选择上下箭头

    https://prnt.sc/QxbmuP1eTzj5