Why isn't the filter working here?
.btns a {
display: block;
float: left;
text-decoration: none;
text-align: center;
padding: 10px;
margin: 0 5px 0 0;
color: white;
background: #1271C7;
}
.btns a:focus[cat] {
background-color: grey;
}
.btns a[cat="java"]:focus ~ .post div:not([cat="java"]),
.btns a[cat="internet-things"]:focus ~ .post div:not([cat="internet-things"]),
.btns a[cat="blockchain"]:focus ~ .post div:not([cat="blockchain"]) {
display: none;
}
.post div {
display: block;
float: left;
width: 99%;
border: 1px solid black;
margin-top: 20px;
background-color: lightgrey;
}
<div class="btns">
<a href="#" cat="all">Show all</a>
<a href="#" cat="java">Java</a>
<a href="#" cat="internet-things">Internet of Things</a>
<a href="#" cat="blockchain">Blockchain</a>
</div>
<div class="post">
<div cat="java">Everything about Java Spring</div>
<div cat="blockchain">A bitcoin project</div>
<div cat="java">Eclipse IDE Java</div>
<div cat="blockchain">Ethereum tokens ICO</div>
<div cat="internet-things">Walking Fridge</div>
<div cat="blockchain">Bitcoin 3.0</div>
<div cat="internet-things">Aibo</div>
</div>
Not-working example: https://jsfiddle.net/3qbvvt50/2/
While the filter DOES work, when I remove <div class="btns">
from the HTML and remove .btns
from the CSS.
Working example: https://jsfiddle.net/3qbvvt50/3/