Change div background acording to the selected category

If you use wp_list_categories (see Codex), it automatically adds the classes cat-item,cat-item-{ID} and (to the current category being viewed) current-cat. (It also adds current-cat-parent to the parent of the current category).

This should be enough to style any particular category a certain way, and style the current category a particlar way.

However, you can obtain the current category being viewed by, in your category template file, using:

$term = get_queried_object();

The current category’s slug is given by $term->slug. This would allow you to add a certain styling to the current category (the exact details of how to do that would depend on how you were displaying the category links).