I will try to show my problem on some simple example.
What I have?
http://jsfiddle.net/JGzSh/3/
Here is some simple button, which will have onlick events later. When i hover over green div (parent), :hover
works changing its color a bit.
What's the problem?
The problem is, when I hover over yellow part, i want to change background of yellow element, but i don't want to parent :hover
to work.
Question
So how can i disable parent :hover
when hovering over child? (so parent's background will go back to starting color?)
Those are only css rules about hovering so far
.przycisk:hover{
background-color: #383;
}
.skrot:hover{
background-color: red;
}
What have I tried so far?
Thats most important question, I know. I did some research, and so far i found some solutions which could help me, but they all use jQuery, and my question is, if its possible to do it in CSS only, to keep it as simple as possible?
Example of solution in jQuery found in google:
$('.przycisk').hover(function(e){
if($(e.target).is('.skrot')){
// your child span is being hovered over
e.stopPropagation();
}else if($(e.target).is('.przycisk')){
// your parent element is being hovered over
}
});