I need to create a box that contains different content (e.g. Stats, Facts, Quotes) which is database-driven, so the content will change.
The styles need to also change dynamically.
For instance, in all cases let’s say I have a rounded box that is 50 x 50 pixels, however,…
For for fact #1, I want a white background and blue font.
For quote #2, I want a tan background and dark-brown border and font.
For stats #3, I want a black background and white font.
Is there some way I can set up the styles so I can change them dynamically?
I was thinking of somehow storing a pre-defined style in the database along with the content, and then my PHP could grab that and turn it into the appropriate HTML/CSS.
I am trying to create an info box that has rotating content. The problem is the content is different size, so I think I need to hard-code the styles tot he specific text.
For example…
Info #1:
35
Number of pizzas avg American eats each year.
Info #2:
10,399
Avg number of text messages a teen sends each year.
Info #3:
7
Continents on Earth.
Each of those would be in a fixed 50 x 50 div box. Depending on the number of digits in the number on the first line, I would need a different style. Likewise, if the text is short like in the last example, I could use larger font.
Since the PHP function I am writing returns a random fact/stat, I’m not sure the most efficient way to do the CSS.
For what I am working on now - and really a lot of my websites - it seems like if I created styles for different things like Size, Color, etc then I could more easily combine styles to get what I want without a whole bunch of “one-off” styles which is what I have now…