Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 551555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:24:22+00:00 2026-05-13T11:24:22+00:00

I have about 200 CSS files like this: /** * GeSHi Dynamically Generated Stylesheet

  • 0

I have about 200 CSS files like this:

/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for bnf
 * CSS class: , CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.bnf .de1, .bnf .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.bnf  {font-family:monospace;}
.bnf .imp {font-weight: bold; color: red;}
.bnf li, .bnf .li1 {font-weight: normal; vertical-align:top;}
.bnf .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.bnf .li2 {font-weight: bold; vertical-align:top;}
.bnf .sy0 {color: #000066; font-weight: bold;}
.bnf .st0 {color: #a00;}
.bnf .st1 {color: #a00;}
.bnf .re0 {color: #007;}
.bnf .ln-xtra, .bnf li.ln-xtra, .bnf div.ln-xtra {background-color: #ffc;}
.bnf span.xtra { display:block; }

But colors in these CSS files are designed to look ok only on light (preferably white) backgrounds. Is there an algo (I can express in PHP code) I can apply to colors in these files to make them look nice on dark backgrounds (close to black)? May be I should just invert all colors? Or is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:24:23+00:00Added an answer on May 13, 2026 at 11:24 am

    To convert all color values found from an CSS file to their inverse values, you can use this function:

    function inverseColors($css) {
        preg_match_all('/#([a-f0-9]{6}|[a-f0-9]{3})/i', $css, $matches);
        $original = $matches[0];
        $inversed = array();
        foreach($matches[1] as $key => $color) {    
            $parts = str_split($color, strlen($color) == 3 ? 1 : 2);
            foreach($parts as &$part) {
                $part = str_pad(dechex(255 - hexdec($part)), 2, 0, STR_PAD_LEFT);
            }
            $inversed[$key] = '#'.implode('', $parts);    
        }
    
        $css = str_replace($original, $inversed, $css);
        echo $css;
    }
    

    That’ll work on both three and six digit hex color values. But note that this will not result in optimal colors, inverse color will probably not be the best for your layout. Better results could be achieved by creating a lookup table for all colors and substituting those values in the new CSS.

    To loop through all CSS files, you can use SPL classes to do a recursive search, then replace the CSS files using

    file_put_contents($file, inverseColors(file_get_contents($file)));
    

    Take a look at PHP’s documentation about glob to learn more how to iterate directories recursively (in the comments section).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 295k
  • Answers 295k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Well it seems a single float on the containing box… May 13, 2026 at 6:57 pm
  • Editorial Team
    Editorial Team added an answer That's simply not going to happen. Binding exceptions occur at… May 13, 2026 at 6:57 pm
  • Editorial Team
    Editorial Team added an answer Apart from the problem with the parentheses that others have… May 13, 2026 at 6:57 pm

Related Questions

I have Java webserver (no standard software ... self written) . Everything seems to
I have multiple text files with logged data like this: 6/23/09 17:00 0.443 6/23/09
UPDATE 2009-05-21 I've been testing the #2 method of using a single network share.
I am trying to build this very simple (visually speaking) layout using HTML/CSS that
I have a iframe that i want to open pdf's into from a list

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.