Skip to content

Instantly share code, notes, and snippets.

@wrumsby
Created February 18, 2014 19:48
Show Gist options
  • Save wrumsby/9078538 to your computer and use it in GitHub Desktop.
Save wrumsby/9078538 to your computer and use it in GitHub Desktop.
Use an attribute selector to hide when count is 0.
/**
* Use an attribute selector to hide when count is 0.
*/
body {
font-family: sans-serif;
}
.badge {
display: inline-block;
padding: 3px;
min-width: 14px;
border-radius: 10px;
box-shadow: 2px 2px 6px #444;
background-color: #f00;
color: #fff;
font-weight: bold;
font-size: 10px;
text-align: center;
}
.badge[data-count="0"] {
display: none;
}
<!-- content to be placed inside <body>…</body> -->
<span class="badge" data-count="0">0</span>
<span class="badge" data-count="1">1</span>
// alert('Hello world!');
{"view":"split","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment