简体   繁体   English

反转html表格中每个单元格的背景颜色

[英]Reverse background color for each cell in html table

I have an html table of unicode numbers in varying colors and I'd like to do 2 things.我有一个包含不同颜色的 unicode 数字的 html 表,我想做两件事。

  1. Have the background for each cell be the reverse color of the unicode symbol color.让每个单元格的背景颜色与 unicode 符号颜色相反。
  2. The circled numbers are not all the same size.圈出的数字大小不一。 How can I insure the same size and alignment of all symbols in the table.如何确保表中所有符号的大小和对齐方式相同。

Here is a sample row.这是一个示例行。

<table>
<tr>
<td align="center;"><mark class="unicode" style="color: #ffbf00; font-size: 15em; font-weight: bold;">①</mark></td>
<td align="center;"><mark class="unicode" style="color: #b5c306; font-size: 15em; font-weight: bold;">②</mark></td>
<td align="center;"><mark class="unicode" style="color: #b87333; font-size: 15em; font-weight: bold;">③</mark></td>
<td align="center;"><mark class="unicode" style="color: #1560bd; font-size: 15em; font-weight: bold;">④</mark></td>
<td align="center;"><mark class="unicode" style="color: #614051; font-size: 15em; font-weight: bold;">⑤</mark></td>
</tr>
</table>

Here is a jsfiddle link.是一个jsfiddle链接。

You can apply a different coloration to the background and the same color for the unicode to have the needed result when using mix-blend-mode .在使用mix-blend-mode时,您可以对背景应用不同的颜色并对 unicode 应用相同的颜色以获得所需的结果。 To have the same size, consider monospace as font-family .要具有相同的大小,请将monospace视为font-family

You can also adjsut padding / line-height to control the spaces:您还可以调整padding / line-height来控制空格:

 table, th, td { border: 1px solid black; } td { padding:0 1.5em 1.5em; } mark { font-size: 20em; font-weight: bold; mix-blend-mode: exclusion; color: #fff; background: transparent; font-family: monospace; line-height:0.6; }
 <table style="width: 10%;" border="0"> <tbody> <tr> <td style="background-color: #ffbf00"><mark class="unicode">①</mark></td> <td style="background-color: #b5c306"><mark class="unicode">②</mark></td> <td style="background-color: #b87333;"><mark class="unicode">③</mark></td> <td style="background-color: #1560bd;"><mark class="unicode">④</mark></td> <td style="background-color: #614051"><mark class="unicode">⑤</mark></td> </tr> </tbody> </table>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM