Hey everyone.

I haven't been on DaniWeb in a while.

.x-accordion-header {
	width: 100%;
	color: #ffffff;
	background-image: -webkit-gradient(linear,0% 0,0% 100%,color-stop(0%,#[B]96A9C0[/B]),color-stop(2%,#[B]5A7596[/B]),color-stop(100%,#[B]394B5F[/B]));
}

Is it possible to include a 'variable' or 'property' in css?

The reason why I am asking is because I want to change the background colour of the css header for multiple object types.

Say I checked for the type either via PHP or Javascript with a case statement or an IF ELSE ... I would want to be able to assign a certain colour based on the object type to the headers css.


Any hints or tips or suggestions would be appreciated.


Many Thanks
:-/

Recommended Answers

All 2 Replies

No, you can't use variables or placeholders in CSS. Why would you even want to, though?

Using PHP, it's as simple as assigning a second class (.green for green background, .blue for blue background, etc.) and you should be covered.

thanks for your reply

I'm very new to php, so I automatically started trying to think of a solution in a syntax I was familiar with (sort of - I have a lot to learn)

I was thinking maybe about using javascript 'prototype' to overwrite the css style applied with a new one based on a certain type ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.