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 15 posts - 1 through 15 (of 18 total)
  • Author
    Posts
  • #33980
    The-Marshal
    Member

    Hi all

    How to make Dynamic CSS, and import it to my php page ??

    Thanx in advance.

    #85271
    TheDoc
    Moderator

    Pardon? What about the CSS do you want to be dynamic?

    #85276
    Ampitere
    Participant

    Are you talking about media queries for multiple devices such as iPhones and Androids?

    #86617
    The-Marshal
    Member

    Thanx for replay

    I need to make PHP inside CSS

    #86618
    chrisburton
    Participant

    You can’t do that. Be specific in what you’re trying to do.

    #86621
    The-Marshal
    Member

    look in JQuery in can with this code

    AddType application/x-httpd-php .js

    so i thought i can make same thin for css

    #86624
    chrisburton
    Participant

    Aah, with .htaccess

    #86625
    WouterJ
    Member

    Yes, it’s possible to do this. You must save you’re css file as .php and echo some PHP in this .css.php file. At the top (no space before it) you place the following code:

    Now the browser use this file as an css file, but php things work. Withing the page you can load it:

    #86747
    The-Marshal
    Member

    thanx all

    WouterJ Thanx , but not working Look to the code below :

    this is an index.php page









    HI





    and this is a style.css.php page :




    body{
    background: ;
    }

    Could you please correct the code if any mistake !

    #86754
    Johann
    Member

    the style.css.php page needs to have the content-type header – not your index.php! It’s the stylesheet that needs to be served as text/css.

    #86800
    The-Marshal
    Member

    wow amazing thanx alot it’s working!

    #242420
    Edison Lazar
    Participant

    hi, thanks in advance

    how can i include this .css.php file

    #242422
    Beverleyh
    Participant

    You’d link to it in the <head> section of your web page, just like any other stylesheet. The only difference is that it would have the .php extension;

    <link rel="stylesheet" href="/path/to/stylesheet.php" />
    
    #242423
    Edison Lazar
    Participant

    it does n’t work for me

    #242425
    Beverleyh
    Participant

    stylesheet.php;

    <?php
    header("Content-type: text/css");
    
    $bg_color = '#ff0000';
    ?>
    
    html { background:<?php echo $bg_color;?> }
    

    Web page header;

    <link rel="stylesheet" href="/path/to/stylesheet.php" />
    
Viewing 15 posts - 1 through 15 (of 18 total)
  • The forum ‘CSS’ is closed to new topics and replies.