在 Angular Material 中隐藏 mat-form-field 中的箭头

14 html css angular angular-material-6

我在用mat-form-field来输入电话号码。这是我的基本代码。

\n
<mat-form-field class="full-width">\n  <input matInput type="number" placeholder="Telefonnummer f\xc3\xbcr R\xc3\xbcckruf" value="" [(ngModel)]="this.inputValues.phone">\n</mat-form-field>\n
Run Code Online (Sandbox Code Playgroud)\n

顺便说一句,当我将鼠标悬停在该组件上时,该组件会显示箭头/旋转按钮。

\n

请让我知道如何自定义此组件,使其不再显示箭头/旋转按钮。

\n

亲切的问候\n杰

\n

小智 18

只要输入类型为 ,就会出现箭头/旋转器number。可以使用 css/scss 删除它。此链接提供了示例以及更多信息。

试试这个 css/scss 代码:

/* Chrome, Safari, Edge, Opera */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type=number] {
  -moz-appearance: textfield;
}
Run Code Online (Sandbox Code Playgroud)


Jul*_*Liu 6

当您将以下 CSS 代码添加到 时style.css,它应该被隐藏。

/* Chrome, Safari, Edge, Opera */
input[matinput]::-webkit-outer-spin-button,
input[matinput]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[matinput][type=number] {
  -moz-appearance: textfield;
}
Run Code Online (Sandbox Code Playgroud)