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
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.

Link to comment
Share on other sites

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. : ).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.