WordPress.org

Forums

Background colour rotation (2 posts)

  1. ssor
    Member
    Posted 5 years ago #

    Hello,

    I'd like to try switching the background colour of my blog on each visit automatically. I assume this is done with some simple CSS and PHP? Can anyone point in the right place?

    Thanks in advance

    ssor

  2. ssor
    Member
    Posted 5 years ago #

    I have found the following script, as used by Tweetcc, but unsure where to call it:

    <?php
    // choose a random background colour
    // list of HEX colours to choose from
    $colors = array('253e76','340d0e','5d2901');

    // randomly select a colour from the list
    $bgColour = $colors[rand(0,count($colors)-1)];
    echo 'html { background: #'.$bgColour.';}';
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic