[value="All"]:checked ~ .targets [data-category] { display: block; } [value="a"]:checked ~ .targets .target_c:not([data-category~="a"]){ display: none; } [value="b"]:checked ~ .targets .target_c:not([data-category~="b"]){ display: none; } .checked_animation { animation: checked_animation 0.6s ease-in-out both; } @keyframes checked_animation { 0% { transform: translate(0, 30px); opacity: 0; } 100% { transform: translate(0, 0); opacity: 1; } }