You'll at least need JavaScript for that.
First you need a function that can read the variables in the URL:
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return pair[1];}
}
return(false);
}
Now let's say you want to change the css of the element with id element1
if(getQueryVariable("theme") == "red") {
document.getElementById("element1").className = "redClass";
} elseif(getQueryVariable("theme") == "yellow") {
document.getElementById("element1").className = "yellowClass";
}
Of course you need to create the css classes (in this example redClass
and yelloClass
) first, but that's pretty much how it could work out.
edit: As requested by OP, here's a working demo. JsFiddle apparently doesn't like GET parameters, so just copy it to an html file an try for yourself. ?theme=red
will make the text red. ?theme=yellow
will make the text yellow.
<style>
.redClass {
color: red;
}
.yellowClass {
color: yellow;
}
</style>
<div id="element1">This is a test</div>
<script>
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return pair[1];}
}
return(false);
}
if(getQueryVariable("theme") == "red") {
document.getElementById("element1").className = "redClass";
} else if(getQueryVariable("theme") == "yellow") {
document.getElementById("element1").className = "yellowClass";
}
</script>