css-php: Is there any way to determine if a color value is close to white?

Source: Internet
Author: User
Demand:
Because the background of some white text is close to white, it will cause the text to be invisible, so it is necessary to set the text color to black for this kind of background color.

Known Invalid method:

Turn the color into 10 to not be able to determine whether it is close to white

红色的值虽然是16711680 但和白色可以很好的区分.但是灰色 12632256 比红色要小,但是和白色是很难区分的.

Reply content:

Demand:
Because the background of some white text is close to white, it will cause the text to be invisible, so it is necessary to set the text color to black for this kind of background color.

Known Invalid method:

Turn the color into 10 to not be able to determine whether it is close to white

红色的值虽然是16711680 但和白色可以很好的区分.但是灰色 12632256 比红色要小,但是和白色是很难区分的.

The reverse. The smaller the brighter the more

Use the RGB value to judge can, find an unclear font to take a color, satisfy at the same time greater than the RGB value of the affirmation is not clear, you can also add a mean to judge

Each of the RGB to the decimal and 255 to compare, for example, each value and 255 of the gap is within 5, then it is determined that he and white very close, and can not directly convert the entire hexadecimal to decimal.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.