SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    avoiding too much of the same values throughout a long css

    I'm currently redesiging my site and luckily for me its only one css file I need to edit to give the whole site a new look. But that css is about more then 450 lines long and the design is based on only 2 foreground and 3 background base-colors. This means that every time I want to test a new scheme, I have to go through all the lines , search out that color I want to change and edit at least 25 instances of that color to the new value.

    So, I'm wondering.. isnt there a way to simplify this ? Just define the colors at the start of the css, and then they should be changed all over the css.

    The site is in PHP, and I'm almost thinking to do the css file like this :
    PHP Code:
    $color1 "#ff55aa";

    a.menu{color $color1font-family VerdanaGeneva ;font-size 12px;}

    div.box{border 1px solid $color1; }

    div.list{ color $color1 text-align:right; } 
    Now I realize that this is a weird mix of php and css that will not work .. but I hope you understand how I want to simplify the use of this css file.

    So is there some way to do this ?

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ctrl + H ?

  3. #3
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Search and Replace (is that what ctrl+H does? )
    Mike
    It's not who I am underneath, but what I do that defines me.

  4. #4
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In most editors, yes

  5. #5
    Phil fillup07's Avatar
    Join Date
    May 2002
    Location
    Jacksonville, FL
    Posts
    1,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do a search and replace, but I suggest using PHP similarly to what you posted. I'm not a PHP guy but you *can* do it with PHP and it will work. You'll probably have to save your .css file as .php, but that will work.

    I think why it might be working, is because you're not switching between the PHP and CSS/HTML in your code. For example, in ASP... it would have to be like this:

    Code:
    <% color1 = "#ff55aa" %>
    a.menu{color : <% =color1 %>; font-family : Verdana, Geneva ;font-size : 12px;}
    div.box{border : 1px solid $color1; }
    div.list{ color : <% =color1 %> ; text-align:right; }

  6. #6
    SitePoint Enthusiast
    Join Date
    Nov 2002
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And in PHP I believe that would be:

    <?php $color1="#ff55aa"; ?>
    a.menu{color : <?=$color1?>; font-family : Verdana, Geneva ;font-size : 12px;}
    div.box{border : 1px solid $color1; }
    div.list{ color : <?=$color1?> ; text-align:right; }

  7. #7
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    198
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks for the reactions:

    - I knew about the search&replace function for the program I use (homesite 4.5) , but it was more of a scripting question.

    - audiolizard/fillup07 : your posts gave me the idea for something better : a php script that re-writes the css when I feed it with new colors. Just a simple form to enter the basecolors, write the file with all the colorvalues in the right place, and then read the css file again to show the newly used values into the form so you can easily change them later.

  8. #8
    SitePoint Zealot
    Join Date
    Jan 2002
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do:
    PHP Code:
    <?php
    $color1 
    "#FF55AA";

    echo 
    "
    a.menu{color:
    $color1;font-family:Verdana, Geneva;font-size:12px;}
    div.box{border:1px solid 
    $color1;}
    div.list{ color:
    $color1;text-align:right;}
    "
    ;
    ?>
    InQuE

  9. #9
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmm, maybe it's possible to define your own color "entities" in a dtd?
    Must do some research...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •