如何对齐DIV与Mat-Expansion-Panel-Header?
我被Angular的matexpansionModule
所困。 在Mat-Expansion-Panel-Header
部分中,我想显示一个图像和简短描述。 但是,图像和描述不会自动适应该部分。
<mat-expansion-panel>
<mat-expansion-panel-header>
<div class="msg-header-img">
<img [src]="picture" alt="pic description" />
</div>
<div class="msg-header-description">
<h4>Hello</h4>
<h6>{{ userName }}</h6>
</div>
</mat-expansion-panel-header>
<p>some content</p>
</mat-expansion-panel>
如何正确地对此进行样式,以便在扩展的标题部分正确渲染图像和描述?
编辑: style-sheet:
mat-expansion-panel {
background-color: blueviolet;
color: white;
position: absolute;
top: 0;
right: 0;
width: 25%;
}
.msg-header-img {
border-radius: 50%;
width: 40px;
margin-top: 10px;
padding-right: 10px;
background-color: rgb(72, 72, 97);
}
.msg-header-description {
width: auto;
float: left;
margin-top: 10px;
}
.msg-header-description h4 {
font-size: 16px;
width: 100%;
color: #fff;
}
.msg-header-description h6 {
font-size: 10px;
line-height: 2px;
color: #fff;
}
mat-expansion-panel-header {
background-color: red;
}
I am stucked with the MatExpansionModule
from Angular.
In the mat-expansion-panel-header
part, I would like to display an image and a short description.
However, the image and description do not automatically adapt to the section.
<mat-expansion-panel>
<mat-expansion-panel-header>
<div class="msg-header-img">
<img [src]="picture" alt="pic description" />
</div>
<div class="msg-header-description">
<h4>Hello</h4>
<h6>{{ userName }}</h6>
</div>
</mat-expansion-panel-header>
<p>some content</p>
</mat-expansion-panel>
How can this be styled correctly so the image and description is rendered correctly in the header part of the expansion?
Edit:
style-sheet:
mat-expansion-panel {
background-color: blueviolet;
color: white;
position: absolute;
top: 0;
right: 0;
width: 25%;
}
.msg-header-img {
border-radius: 50%;
width: 40px;
margin-top: 10px;
padding-right: 10px;
background-color: rgb(72, 72, 97);
}
.msg-header-description {
width: auto;
float: left;
margin-top: 10px;
}
.msg-header-description h4 {
font-size: 16px;
width: 100%;
color: #fff;
}
.msg-header-description h6 {
font-size: 10px;
line-height: 2px;
color: #fff;
}
mat-expansion-panel-header {
background-color: red;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的布局是错误的。您还应该使用Mat-Panel-title和Mat-Panel-Description来管理一些责任,以便您可以简化:
Your layout is wrong. You should also use mat-panel-title and mat-panel-description to manage some of the responsibility so that you can simplify: