What I'm trying to do should be simple but I don't know of any tricks or methods to accomplish it.
I have an element on my page. A 100x100 div with a class of 'fooditem'
When you hover, it gets a blue border
When you click, it gets a permanent green border
The issue is :hover and the base clases are competing. I want :hover to only apply to elements without the .fooditem-selected class.
Here's a fiddle to play with it. It works pretty much how I want, but I know I'm using conflicting css rules: http://jsfiddle.net/96BHd/2/
Is there a simple fix or trick that I am overlooking?
CSS
.fooditem { width: 100px; height: 100px; border: 1px solid grey; } .fooditem:hover { transition: .5s; box-shadow: inset 0 0 0 6px #4F91FF; } .fooditem-selected { transition: .5s; box-shadow: inset 0 0 0 6px #6dff70; } .fooditem-selected:hover { box-shadow: inset 0 0 0 6px #6dff70; } JS
$(".fooditem").click(function(){ if($(this).hasClass("fooditem-selected")){ $(this).removeClass("fooditem-selected"); } else { $(this).addClass("fooditem-selected"); } });