我需要对角划分Mat Table单元格。并且需要根据值添加值和颜色。这样...
这是我的代码.html
<ng-container matColumnDef="RearIdler">
<mat-header-cell class="eval-header" *matHeaderCellDef> {{Translate('Rear Idler')}} </mat-header-cell>
<mat-cell *matCellDef="let row" class="no-padding">
<div>
<span class="component-span top {{getComponentHoursClass(7,1, row.Components)}}">
{{getComponentHours(7,1, row.Components)}}
</span>
<span class="component-span top {{getComponentClass(7,1, row.Components)}}">
{{getComponentValue(7,1, row.Components)}}%
</span>
</div>
<div>
<span class="component-span bottom {{getComponentHoursClass(7,2, row.Components)}}">
{{getComponentHours(7,2, row.Components)}}
</span>
<span class="component-span bottom {{getComponentClass(7,2, row.Components)}}">
{{getComponentValue(7,2, row.Components)}}%
</span>
</div>
</mat-cell>
</ng-container>
.css
.component-span {
display:block;
border-radius: 4px;
text-align: center;
margin: 1px;
padding: 4px 2px;
font-size: 12px;
}
答案 0 :(得分:1)
如CSSDesk http://www.cssdesk.com/RERXd
所示CSS / HTML
div.all {
margin:20px;
width:200px;
height:120px ;
background-color:#ee0;
position:relative;
font-size:40px;
}
div.top {
width: 0;
height: 0;
border-top: 120px solid #ffb;
border-right: 200px solid transparent;
}
div.mid {
position:absolute;
top:0;
left:0;
}
div.bot {
position:absolute;
bottom:0;
right:0;
}
div.mid, div.bot {
padding:5px;
}
<table><tr><td>
<div class="all">
<div class="top"></div>
<div class="mid">-261</div>
<div class="bot">22.1%</div>
</div>
</td></tr></table>
答案 1 :(得分:0)
尝试一下:
body {
background-color: burlywood
}
.main {
margin: 50px;
overflow: hidden;
position: relative;
width: 100px;
height: 50px;
background-color: aqua;
}
.text {
height: 25px;
}
.percentage {
background-color: transparent;
text-align: right;
height: 25px;
position: relative;
}
.percentage>div {
position: relative;
z-index: 1;
}
.percentage:before {
content: "";
background-color: white;
position: absolute;
height: 60px;
width: 120px;
top: 0;
left: 0;
transform: rotate(-27deg);
z-index: 0;
}
<div class="main">
<div class="text">203</div>
<div class="percentage">
<div>
95%
</div>
</div>
</div>
width
中的{li> height
和.main
width
中的{li> height
,transform
和.percentage:before
希望获得帮助