JSFiddle
When you click the button
, you see that :active
pseudoclass is triggered for the parent div
. Is ther
Perhaps the simplest way of achieving what you probably really want to do is to put not put the button inside the div
you don't want activated.
Here, you have a container div
, which contains a background div
(the equivalent of the parent div
in your original example). The background div
has an active state separate from the button's.
.container {
position: relative;
width: 200px;
height: 200px;
}
.background {
position: absolute;
width: 100%;
height: 100%;
border: 1px solid black;
background-color: #eee;
}
.background:active {
background-color: red;
}
button {
position: relative;
}