javascript - setting white font color for dark background and V.S. in php - Stack Overflow

while changing to dark background , I need to set the font color to white and exactly in opposite , whe

while changing to dark background , I need to set the font color to white and exactly in opposite , when the background is bright so the font color should be black

i don't the range to divide the dark and light colors in php

my color codes are in hex format #ffffff

while changing to dark background , I need to set the font color to white and exactly in opposite , when the background is bright so the font color should be black

i don't the range to divide the dark and light colors in php

my color codes are in hex format #ffffff

Share Improve this question edited Jul 19, 2011 at 18:38 Mac Taylor asked Jul 19, 2011 at 18:28 Mac TaylorMac Taylor 5,16615 gold badges53 silver badges75 bronze badges 4
  • I think this is a css, or javascript question, not php? – citizen conn Commented Jul 19, 2011 at 18:29
  • are you trying to have alternate rows in a table? One row white, the next row black, and so on? – Paul S. Commented Jul 19, 2011 at 18:33
  • nah , just read the question , its about guessing the white or black font color according to dark or light background ,, I mean how to devide hex color codes to dark and light colors so that we can set font colors such as black and white to them. – Mac Taylor Commented Jul 19, 2011 at 18:40
  • @Mac. Could you provide more context? Where are the background colors ing from? Are they dynamically generated on different pages? – Jason Gennaro Commented Jul 19, 2011 at 18:43
Add a ment  | 

3 Answers 3

Reset to default 6

I found this method working for my issue. http://www.webmasterworld./forum88/9769.htm

You could take the three parts of your color (red, green and blue) and build the sum. The minimum value you will get is 0 and the maximum value is 765. You could say that values below 380 are dark and values above are bright and set the text color accordingly.

Or you take the HSV definition and say that value := max(red, green, blue) and values above 128 are bright and values below are dark

There is no "real definition" of a dark background. You could switch from one type to the other if the contrast (eg. the sum of the R, G and B differences) is not high enough.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744171297a4561548.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信