Skip to content

Instantly share code, notes, and snippets.

@webverstalshik
Created February 24, 2016 19:57
Show Gist options
  • Select an option

  • Save webverstalshik/e2f9aae9e9d3aae3e2bb to your computer and use it in GitHub Desktop.

Select an option

Save webverstalshik/e2f9aae9e9d3aae3e2bb to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Data-filter HTML 5</title>
<style>
section{
display:block;
float:left;
border:2px solid green;
min-height:300px;
width:100%;
border-radius:4px;
}
a{
display:block;
float:left;
width:25%;
text-decoration:none;
text-align:center;
padding:5px 0;
color:white;
background:#1271C7;
}
div{
display:block;
float:left;
height:40px;
width:40px;
border:1px solid black;
margin:10px;
-webkit-transition:all .8s linear;
-moz-transition:all .8s linear;
-o-transition:all .8s linear;
-ms-transition:all .8s linear;
transition:all .8s linear;
margin-top:20px;
}
div[data-filter="red"]{
background:red;
}
div[data-filter="green"]{
background:green;
}
div[data-filter="blue"]{
background:blue;
}
a:focus[data-filter]{
opacity:.8;
outline:none;
}
a[data-filter="red"]:focus ~ div:not([data-filter="red"]){
height:0px;
width:0px;
border:none;
margin:0;
}
a[data-filter="green"]:focus ~ div:not([data-filter="green"]){
height:0px;
width:0px;
border:none;
margin:0;
}
a[data-filter="blue"]:focus ~ div:not([data-filter="blue"]){
height:0px;
width:0px;
border:none;
margin:0;
}</style>
</head>
<body>
<section>
<a data-filter="all" tabindex="-1">ALL</a>
<a data-filter="red" tabindex="-1">RED</a>
<a data-filter="green" tabindex="-1">GREEN</a>
<a data-filter="blue" tabindex="-1">BLUE</a>
<div data-filter="red"></div>
<div data-filter="blue"></div>
<div data-filter="red"></div>
<div data-filter="blue"></div>
<div data-filter="green"></div>
<div data-filter="red"></div>
<div data-filter="red"></div>
<div data-filter="red"></div>
<div data-filter="blue"></div>
<div data-filter="green"></div>
<div data-filter="blue"></div>
<div data-filter="green"></div>
<div data-filter="green"></div>
</section>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment