Jump to content

Hi everyone, hope you're having a good day 🙂

I've been working lately on a type of website that reports results exported from a server every 5 minutes.

Working on CSS over XML --> Can't do changes to the XML file so I'm alone fighting with CSS.

 

I've made an status square with a number of the same background color inside of it.

It should change color depending on the status.

 

Is there a way to make an "if" condition on pure CSS like:

if:status = 1 {

    background-color: green;

    color: green;

} elseif:status = 2 {

    background-color: yellow;

    color: yellow;

}

and so on with red color...

 

 

The right-side green square should change color depending on the number(status).

<status>1</status> --> Green

<status>2</status> --> Yellow

<status>3</status> --> Red

 

 

image.thumb.png.8ad007d7833f9af8ce7822cdf56e522f.png

 

 

Been fighting with this for at least a month now, the only thing remaining is the color change depending on status.
Thank you everyone for your time and knowledge!! 🙂

3700x PBO stock | b550-f | Crucial Ballistix 32GB 3200MHz | RTX 4080 Asus TUF OC | SN 850X 2TB - SN 850 1T | Cooler Master XG 850w Platinum PSU

Link to comment
https://linustechtips.com/topic/1462012-if-condition-on-pure-css-possible/
Share on other sites

Link to post
Share on other sites

Have a look at CSS Selectors : https://www.w3schools.com/cssref/css_selectors.asp

But I'm not sure it's possible.

 

Don't know why you don't just parse the xml to extract the data and generate your own html code.

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×