Manxandrew Posted March 26, 2012 Share Posted March 26, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/259757-css-and-php-help-needed/ Share on other sites More sharing options...
smerny Posted March 26, 2012 Share Posted March 26, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/259757-css-and-php-help-needed/#findComment-1331319 Share on other sites More sharing options...
Manxandrew Posted March 26, 2012 Author Share Posted March 26, 2012 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. : ). Quote Link to comment https://forums.phpfreaks.com/topic/259757-css-and-php-help-needed/#findComment-1331321 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.