Set int color based on positive or negative value with CSS
3 answers
It depends on the language you are using. In almost any language, you can set a tag class around a value using the dynamic part of the language. If the value has no tags of its own, you can use <span></span>
around the value to give it a class. then you just use dynamic code to set the class.
If you are using the Ruby language, there are some CSS selector gems you can use, but I know little about them or if they help.
0
a source to share
I am using wordpress and the table with new posts and custom posts is at index.php, the code I paste between the td tags
<td style="font-weight: <?php echo ($var <= 0 ? 'normal' : 'bold'); ?>"><?php echo get_portf_posts_count_from_last_24h(); ?></td>
I tried this code too and it doesn't work:
<?php
if ($output <= 0) {
$output = 'normal';
print $output;
}
else // +
{
$output = 'bold';
print $output;
}
?>
0
a source to share