【问题标题】:Need to split the mat table cell diagonally and add values需要对角分割mat表格单元格并添加值
【发布时间】:2019-05-10 21:41:08
【问题描述】:

我需要对角分割 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;
}

【问题讨论】:

    标签: html css angular angular5 mat-table


    【解决方案1】:

    试试这个:

        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>
    您需要调整这些 CSS 属性以匹配您的代码:
    • widthheight.main
    • widthheighttransform.percentage:before

    希望有帮助

    【讨论】:

      【解决方案2】:

      如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>

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-07-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-11-19
        • 2018-10-04
        相关资源
        最近更新 更多