英文:
Angular Material 15 - How to change border color of a mat-mdc-form-field outline
问题
<p>
<mat-form-field appearance="outline">
<mat-label>轮廓表单字段</mat-label>
<input matInput placeholder="占位符">
<mat-icon matSuffix>sentiment_very_satisfied</mat-icon>
<mat-hint>提示</mat-hint>
</mat-form-field>
</p>
mat-form-field{
background-color: #f3f6f9; // 成功
border:2px solid red; // 这会添加另一个边框,所以不能解决问题
}
英文:
How do i change mat-form-field apearance outline underline color in Angular Material **Version 15 **
this post stackoverflow were great helpful but i could not change border color with this because we have not $border propertie on mat.define-typography-level( )
material.angular.io
<p>
<mat-form-field appearance="outline">
<mat-label>Outline form field</mat-label>
<input matInput placeholder="Placeholder">
<mat-icon matSuffix>sentiment_very_satisfied</mat-icon>
<mat-hint>Hint</mat-hint>
</mat-form-field>
</p>
I tried to overide border without success
mat-form-field{
background-color: #f3f6f9; // success
border:2px solid red; // it's add another border so not resolve
}
答案1
得分: 1
我是你的中文翻译:
// 顶部和底部边框,如果标签在内部
::ng-deep.mdc-notched-outline__notch {
border-top: 2px solid red !important;
border-bottom: 2px solid red !important;
}
// 顶部和底部边框,如果标签是凹陷的
::ng-deep.mdc-notched-outline--notched {
::ng-deep.mdc-notched-outline__notch {
border-top: none !important;
border-bottom: 2px solid red !important;
}
}
// 带有边缘的左边框
::ng-deep.mdc-notched-outline__leading {
border: 2px solid red !important;
border-right: none !important;
}
// 带有边缘的右边框
::ng-deep.mdc-notched-outline__trailing {
border: 2px solid red !important;
border-left: none !important;
}
英文:
I have achieved it this way. So it works, but maybe there is an easier way. I found the neccessary CSS-Classes on the offical MDC Docs
//Top bottom border, if label is inside
::ng-deep.mdc-notched-outline__notch {
border-top: 2px solid red !important;
border-bottom: 2px solid red !important;
}
//Top bottom border, if label is notched
::ng-deep.mdc-notched-outline--notched {
::ng-deep.mdc-notched-outline__notch {
border-top: none !important;
border-bottom: 2px solid red !important;
}
}
//Left border with edges
::ng-deep.mdc-notched-outline__leading {
border: 2px solid red !important;
border-right: none !important;
}
//Right border with edges
::ng-deep.mdc-notched-outline__trailing {
border: 2px solid red !important;
border-left: none !important;
}
答案2
得分: 0
你可能正在寻找CSS的outline-color
属性。
例如:
.hide-outline-color:focus-visible {
outline-color: transparent;
}
英文:
You might be looking for css outline-color
property.
EX.
<input class="hide-outline-color" />
then in your css
.hide-outline-color:focus-visible {
outline-color: transparent;
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论