Skip to content

Instantly share code, notes, and snippets.

@storskegg
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save storskegg/5b15295d3a5ad4926130 to your computer and use it in GitHub Desktop.
Save storskegg/5b15295d3a5ad4926130 to your computer and use it in GitHub Desktop.
Ready to Play with :has CSS4 Selector
<div class="has">
<h1 class=".works">:has() CSS4 Selector<br>It's working!</h1>
</div>
<div class="hasnt">
<h1 class=".not-working">:has() CSS4 Selector<br>It isn't working just yet.</h1>
</div>

Ready to Play with :has CSS4 Selector

When your browser supports CSS4 selector :has(), the winning statement will be revealed.

A Pen by Liam Conrad on CodePen.

License.

@import url(http://fonts.googleapis.com/css?family=Raleway:300,400);
body {
background-color: #556;
}
div {
width: 70vmin;
height: 10vmin;
margin: -5vmin -35vmin;
position: absolute;
top: 50%;
left: 50%;
border-radius: 2vmin;
overflow: hidden;
&.hasnt {
background-color: tomato;
}
&.has {
background-color: mediumspringgreen;
}
}
h1 {
position: absolute;
top: 50%;
height: 6vmin;
width: 100%;
margin: -3vmin auto 0;
font-size: 3vmin;
line-height: 3vmin;
text-align: center;
font-family: "Raleway";
font-weight: 400;
letter-spacing: 0.1rem;
color: white;
}
.has {
display: none;
&:has(.works) {
display: block;
&+.hasnt:has(.not-working) {
display: none;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment