Forum Moderators: coopster

Message Too Old, No Replies

PHP + CSS: Can an B.G. image be assigned on the fly?

...would like a different B.G. on each visit

         

Storyman

6:15 pm on Dec 22, 2004 (gmt 0)

10+ Year Member



Is there a way to have PHP assign a B.G. image to CSS?

jatar_k

6:29 pm on Dec 22, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I guess you could have your .css file parsed by php and then write the image dynamically to the file.

I am not a huge fan of that though

You would be better to have the bg image css code in the html/php file and just write the image dynamically to there.

Storyman

6:53 pm on Dec 22, 2004 (gmt 0)

10+ Year Member



What if a specific class was used to design a box and the class is used three times with each instance of the class displaying a different B.G.?

The class could be defined in the header of the page, but how would you go about assigning a different B.G. to each instance of the class?

victor

7:14 pm on Dec 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Code the style directly in the HTML rather than an external file.

Have a variable to substitute in the url(....) bit.

Storyman

7:25 pm on Dec 22, 2004 (gmt 0)

10+ Year Member



Victor,

So if the class is defined in the header portion of the page isn't that where you will define the url for the image also?

What I don't understand is that once you have defined the class in the header how do you change the url for the class when used within the body. I don't think span can be used to define the background (not 100% certain, just 80%).

My question slops over into pure CSS, so maybe I should post the question there...

jatar_k

7:40 pm on Dec 22, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



show me the css you would use in the <head> for the class

though if you are using the same class for 3 bg's then I have no idea. I would think you need multiple classes where they inherit from the parent class and all that changes is the image