Skip to content

Instantly share code, notes, and snippets.

@markhealey
Last active December 14, 2015 14:59
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 markhealey/5104432 to your computer and use it in GitHub Desktop.
Save markhealey/5104432 to your computer and use it in GitHub Desktop.
Data attribute CSS selector responsive trick
@media (min-width: 768px) and (max-width: 979px) {
[data-hide="minWidth768"] {
/* http://css-tricks.com/places-its-tempting-to-use-display-none-but-dont/ */
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
}
}
<!--
When the viewport is > 768px and < 979px, the text in the span (the button labels) will be hidden
-->
<div class="btn-toolbar">
<div class="btn-group">
<a class="btn btn-small" href="#"><i class="icon-play"></i><span data-hide="minWidth768"> Preview</span></a>
<a class="btn btn-small" href="#"><i class="icon-pencil"></i><span data-hide="minWidth768"> Edit</span></a>
<a class="btn btn-small" href="#"><i class="icon-remove"></i><span data-hide="minWidth768"> Delete</span></a>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment