默认浏览器复选框除了Angular-Material md复选框外还显示

时间:2018-01-05 18:51:00

标签: javascript angular google-chrome checkbox angular-material

enter image description here我在Angular 2应用中使用Angular素材元素,在我使用md-checkboxes的一个部分中,我注意到使用Chrome,这两个版本的UI都是-checkbox为以及看起来像默认浏览器复选框的内容。如何禁用显示的默认浏览器UI复选框?

<md-checkbox class="request-option" [checked]="hasBeenRequested()"
             (change)="onOptionSelected($event, 'ct')">Consulting
</md-checkbox>

以下是根据浏览器应用的样式:

element.style {
}
default-theme.css:205
.chart-content .scroll-panel * {
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}
<style>…</style>
.mat-checkbox-input {
    bottom: 0;
    left: 50%;
}
<style>…</style>
.cdk-visually-hidden {
    border: 0;
    clip: rect(0 0 0 0);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
    position: absolute;
    text-transform: none;
    width: 1px;
}
default-theme.css:195
.chart-content * {
    box-sizing: border-box;
    -moz-box-sizing: border-box;
    -webkit-box-sizing: border-box;
}
default-theme.css:413
input {
    font-size: 14px;
    padding: 8px;
    outline: none;
}
user agent stylesheet
input[type="checkbox" i] {
    -webkit-appearance: checkbox;
    box-sizing: border-box;
}
user agent stylesheet
input[type="radio" i], input[type="checkbox" i] {
    background-color: initial;
    cursor: default;
    margin: 3px 0.5ex;
    padding: initial;
    border: initial;
}
user agent stylesheet
input {
    -webkit-appearance: textfield;
    background-color: white;
    -webkit-rtl-ordering: logical;
    cursor: text;
    padding: 1px;
    border-width: 2px;
    border-style: inset;
    border-color: initial;
    border-image: initial;
}
user agent stylesheet
input, textarea, select, button {
    text-rendering: auto;
    color: initial;
    letter-spacing: normal;
    word-spacing: normal;
    text-transform: none;
    text-indent: 0px;
    text-shadow: none;
    display: inline-block;
    text-align: start;
    margin: 0em;
    font: 400 11px system-ui;
}
user agent stylesheet
input, textarea, select, button, meter, progress {
    -webkit-writing-mode: horizontal-tb;
}

我的&#34;计算&#34;标签显示:

background-color: rgba(0, 0, 0, 0);
border-bottom-color: rgb(0, 0, 0);
border-bottom-style: none;
border-bottom-width: 0px;
border-image-outset: 0px;
border-image-repeat: stretch;
border-image-slice: 100%;
border-image-source: none;
border-image-width: 1;
border-left-color: rgb(0, 0, 0);
border-left-style: none;
border-left-width: 0px;
border-right-color: rgb(0, 0, 0);
border-right-style: none;
border-right-width: 0px;
border-top-color: rgb(0, 0, 0);
border-top-style: none;
border-top-width: 0px;
bottom: 0px;
box-sizing: border-box;
clip: rect(0px 0px 0px 0px);
color: rgb(0, 0, 0);
cursor: default;
display: block;
inline-blockinput, textarea, select, buttonuser agent stylesheet
font-family: system-ui;
font-size: 14px;
font-stretch: 100%;
font-style: normal;
font-variant-caps: normal;
font-variant-east-asian: normal;
font-variant-ligatures: normal;
font-variant-numeric: normal;
font-weight: 400;
height: 1px;
left: 10px;
letter-spacing: normal;
line-height: normal;
margin-bottom: -1px;
margin-left: -1px;
margin-right: -1px;
margin-top: -1px;
outline-color: rgb(0, 0, 0);
outline-style: none;
outline-width: 0px;
overflow-x: hidden;
overflow-y: hidden;
padding-bottom: 0px;
padding-left: 0px;
padding-right: 0px;
padding-top: 0px;
position: absolute;
text-align: start;
text-indent: 0px;
text-rendering: auto;
text-shadow: none;
text-transform: none;
white-space: nowrap;
width: 1px;
word-spacing: 0px;
writing-mode: horizontal-tb;
-webkit-appearance: checkbox;
-webkit-box-direction: normal;
-webkit-rtl-ordering: logical;
-webkit-border-image: none;

2 个答案:

答案 0 :(得分:2)

将类cdk-visually-hidden分配给Angular Material复选框内的HTML输入元素,并使其不可见。如果您没有找到另一种方法来阻止元素显示,您可以将以下样式添加到应用程序的全局CSS文件中:

.cdk-visually-hidden
{
    visibility: hidden;
}

答案 1 :(得分:-3)

请检查,您是否在模块中导入了checbox模块?最好将角度材料升级到最新版本。

import {MatCheckboxModule} from '@angular/material/checkbox';
相关问题