Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS How to make Dynamic CSS??

  • This topic is empty.
Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #242428
    Edison Lazar
    Participant

    when run my html page it shows all source of my page

    #242431
    bearhead
    Participant

    I don’t have much experience on this subject, but it looks like you need to modify your .htaccess file to get this to work. Did you do that step?

    What’s your use case? If you just want variables in your css, you’d probably be better off just using SCSS or the like.

    #242434
    I.m.learning
    Participant

    You don’t have to modify your .htaccess. unless you might be using a WordPress site.

    I did this and it worked fine (not using a WordPress site); but it is a very complicated system.

    Most of the answers are already given, and you have to follow them completely.

    This is what I had done:

    Link to your style.php in the HTML page HEAD:
    <link rel=”stylesheet” type=”text/css” href=”css/style.php”

    In your style.php you have to convert BACK to CSS (this should be your first lines in your style sheet):

    <?php
    header(“Content-type: text/css; charset: UTF-8”);
    — Now set your variables–
    $variable1= “whatever”;
    $variable2=”whenever”;
    $variable3=”however”;
    ?>

    Now you set your normal CSS, but you now can use the variables; also, you must declare the php as you would normally

    #thisID{color:<?php echo $variable;?>; }
    .thisClass{background:<?php echo $variable;?>;

    etc.

    I reverted back to normal CSS because it increased my code; my intention was to reduce the code.

Viewing 3 posts - 16 through 18 (of 18 total)
  • The forum ‘CSS’ is closed to new topics and replies.