简体   繁体   English

根据背景色更改原色

[英]Changing forecolor according to backcolor

I have created an iframe which contains the label, "powered by MyWebsite.site" The "iframe itself" accepts arguments, so other webmasters may customize the appearance of it. 我创建了一个包含标签“由MyWebsite.site技术支持”的iframe。“ iframe本身”接受参数,因此其他网站管理员可以自定义其外观。

The problem is that since the background of the iframe could be customized, anyone can "vanish" the "powered by MyWebsite.site". 问题在于,由于可以自定义iframe的背景,因此任何人都可以“消失”“由MyWebsite.site提供支持”。

So what option do i have? 那我有什么选择呢? How should i dynamically change the label color depending on any background? 如何根据任何背景动态更改标签颜色?

Assuming you have access to the background color (in hex; eg #ff0000) defined by the webmaster, you should be able to invert the color using an algorithm such as the one that follows. 假设您可以访问网站站长定义的背景颜色(以十六进制表示,例如#ff0000),那么您应该能够使用以下算法来反转颜色。 The given algorithm converts the hex color value to RGB. 给定的算法将十六进制颜色值转换为RGB。 Then it subtracts each component of the RGB value from 255, which yields the inverse. 然后,它从255中减去RGB值的每个分量,得出反函数。 The inverted RGB value is then converted back into a hex color value. 然后将反转的RGB值转换回十六进制颜色值。 Apply the inverted hex color value to the "powered by..." text and you should be all set. 将反转的十六进制颜色值应用于“ powered by ...”文本,您应该已全部设置好。

http://www.codingforums.com/archive/index.php/t-47335.html http://www.codingforums.com/archive/index.php/t-47335.html

Note that this calculation can be done directly in hex, but that may be a little more difficult to comprehend (depending on how your mind "thinks" about these things). 请注意,此计算可以直接以十六进制完成,但是可能难以理解(取决于您对这些事情的看法)。

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

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