Add background color to an HTML table cell without using background-color?

后端 未结 2 1089
别跟我提以往
别跟我提以往 2021-01-29 12:47

Is there a way to add (background) color to a table cell other than the background-color style attribute? I have tables with programmatically generated textual content and backg

2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-29 13:27

    You could use an inset box-shadow to cover your background

    td {
      background: red;
      padding: 1em;
    }
    
    td:hover, .highlight {
      box-shadow: inset 0 0 0 50px yellow;
    }
    td.highlight:hover  {/* ? needed ? */
      box-shadow: inset 0 0 0 50px green;
    }
    cell to hover cell to hover cell to highlight

提交回复
热议问题