【问题标题】:How to conditionally strikethrough text in table rows?如何有条件地删除表格行中的文本?
【发布时间】:2019-08-26 10:13:01
【问题描述】:

I wanto strikethrough text in rows when the option "ANL" is selected.颜色样式效果很好,但是当我添加text-decoration:line-through 时,所有表格都有删除线。

有什么想法吗?

$colorMap = [
    "ANL" => 'grey',
    2 => 'red',
    // add more
];

foreach($dane as $s): ?>
    <tr  style=" color:<?php echo $colorMap[$s['nr_d']] ?>;text-decoration:line-through"> 
        
        <form action="uso.php" method="post"> 
            <td ><?=htmlspecialchars($s['id'])?></td>
            <td><?=htmlspecialchars($s['counter'])?> </td>
            <td><?=htmlspecialchars(date('Y-m-d', strtotime($s['data_in'])))?></td>
            <td><?=htmlspecialchars($s['count_mat'])?></td>
            <td><textarea class="small1 noborder" rows="1" cols="20" maxlength="50" name="name_inst"><?=htmlspecialchars($s['name_inst'])?></textarea></td>
            <td><?=htmlspecialchars($s['nr_own'])?></td>
            <td><?=htmlspecialchars($s['data_out'])?></td>
            <td><textarea class="small1 noborder" rows="1" cols="20" maxlength="100" name="info_spr"><?=htmlspecialchars($s['info_spr'])?></textarea></td>
            <td><textarea class="small1 noborder" rows="1" cols="20" maxlength="50" name="count_zal"><?=htmlspecialchars($s['count_zal'])?></textarea></td>
            <td>
                <select class="noborder" name="nr_d" '<?=htmlspecialchars($s['nr_d'])?>'
            </td>"
            >  
                    <option><?=htmlspecialchars($s['nr_d'])?></option>
                    <option>YES</option>
                    <option>NO</option>
                    <option>ANL</option>
                </select>

【问题讨论】:

    标签: php css conditional-statements strikethrough


    【解决方案1】:

    您已将 line-thorugh 附加到所有 &lt;tr&gt; 而不是特定的(具有 ANL 属性)

    text-decoration:line-through 替换为&lt;?php echo $s['nr_d']=="ANL" &amp;&amp; "text-decoration:line-through;" ?&gt;

    或者你可以替换整行

    <tr  style=" color:<?php echo $colorMap[$s['nr_d']] ?>;text-decoration:line-through"> 
    

    &lt;tr style=" color:&lt;?php echo $colorMap[$s['nr_d']].$s['nr_d']=="ANL" &amp;&amp; "text-decoration:line-through; ?&gt;"&gt;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-12
      • 1970-01-01
      • 2016-01-03
      • 2015-08-31
      • 2021-06-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多