Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it acceptable to use the !important directive in this case? [closed]

I dynamically populate a ul by getting data from a DB and using a template engine (mustache) like so:

var template = '<ul class="myList"> {{#.}} ' + 
    '<li class="Foo" ' +
    'style="background-color: {{thisItemsColor}};>" ' +
        '{{someData}}' +
    '</li> ' +
'{{/.}} </ul>';

The color of the list item is stored in the DB. The problem is now I want to change the hover attribute to a different color. I cannot do this via a css file because in the markup I'm setting that attribute directly on the element so I'm doing this:

.myList .Foo:hover {
    background-color:#000033 !important;
}

Is this acceptable or should I use js/jquery to apply this pseudo selector?

like image 436
red888 Avatar asked Jun 23 '14 18:06

red888


People also ask

Why is Directive important?

It helps others know what type of medical care you want. An advance directive also allows you to express your values and desires related to end-of-life care. You might think of it as a living document—one that you can adjust as your situation changes because of new information or a change in your health.

Do you have to follow a directive?

Advance directives are legally binding, so doctors have to follow them. False. Advance directives are legally recognized documents and doctors must respect your known wishes, but doctors can always refuse to comply with your wishes if they have an objection of conscience or consider your wishes medically inappropriate.

What are the 2 most common forms of advance directives?

The most common types of advance directives are the living will and the durable power of attorney for health care (sometimes known as the medical power of attorney). There are many advance directive formats.

What are the most common 3 types of advance directives?

Advance directives include legal documentation such as a living will, power of attorney and do not resuscitate (DNR) orders. The directive documents identify who will make decisions if the patient is unable to and who will be involved in their final care.


1 Answers

To answer this question it's best to go back to the reason why !important is discouraged in the first place: essentially to make the behaviour of your css predictable and extensible without having to check every single class for an !important tag.

My opinion is that this is exactly the use case that !important is designed for. If I were in your situation I'd use it over any inline style manipulation through JavaScript, although I would make it difficult for myself to misuse the CSS class by calling it something like .enforced-hover-highlight.

like image 68
Ed_ Avatar answered Oct 21 '22 03:10

Ed_