Jump to content

CSS and PHP help needed.


Manxandrew

Recommended Posts

Hey, I've recently took up webdesign as a hobby and have been teaching myself html, javascript and css in my spare time, just today I came across a method of using php to create stylesheets so that variables can be used.

 

for example.

 

<?php header("Content-type: text/css"); 
$color = '#FFF';
?>
body{
background-color:<?=$color?>;
}

 

yet I'd like to know if there's a way of changing $color using a button on the webpage itself.

 

I have my files currently set up as such

 

dir/

-page.html

-style.php

 

if that's any help.

Link to comment
https://forums.phpfreaks.com/topic/259757-css-and-php-help-needed/
Share on other sites

if you are interested in that type of thing, you should look into SASS CSS - http://sass-lang.com/

 

as for the button thing.. it sort of depends on if you want it to just change the background for that instant... or if you want it to save in session/cookie/user/whatever... or if you want it to show up that way for everyone accessing the website.

I'd like to use the $color variable multiple times to allow for a switching of colour themes, of course saving it through cookies would be nice too, then you wouldn't have to switch it every time you loaded the page again.

 

I'm already using a good few CSS3 methods as they are un-arguably amazing, so I'll take a look into SCSS and see what I can do with it, but as I know very little js I'd like to learn more, so if there's anything you think you could help me with I'd be happy to listen to you, or read, that's what we do on the internet isn't it. : ).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.