Skip to content

Instantly share code, notes, and snippets.

@alexmwalker
Last active March 6, 2023 22:35
Show Gist options
  • Select an option

  • Save alexmwalker/acf69cf4720af01bb0df9b467828c5d7 to your computer and use it in GitHub Desktop.

Select an option

Save alexmwalker/acf69cf4720af01bb0df9b467828c5d7 to your computer and use it in GitHub Desktop.
Temporary Media Query Device labels for your page
/* Large devices (laptops, 64em and up)*/
.device {
background-position: 66.666% top;
}
.device:after {
content: "Laptop";
}
.laptop-only{
display: inline;
}
.mobile-only, .tablet-only, .wide-only{
display: none;
}
/* TABLETs + small notebooks */
@media (min-width: 48em) {
.device {
background-position: 33.333% top;
}
.device:after {
content: "Tablet";
}
.tablet-only{
display: inline;
}
.mobile-only, .laptop-only, .wide-only{
display: none;
}
}
/* Extra large devices (large desktops, 80em and up)*/
.device {
background-position: right top;
}
.device:after {
content: "Wide";
}
.wide-only{
display: inline;
}
.mobile-only, .tablet-only, .laptop-only{
display: none;
}
.device {
font-size: 18px;
width: 5rem;
height: 5rem;
left: calc(100% - 6rem);
margin: 0 1rem 1rem 0;
position: absolute;
outline: 1px #ddd solid;
background-image: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20fill%3D%27none%27%20viewBox%3D%270%200%20128%2026%27%3E%3Cpath%20fill%3D%27%23fff%27%20d%3D%27M0%200h128v26H0z%27%2F%3E%3Cpath%20fill%3D%27%23aaa%27%20d%3D%27M124.1333%2018.0417c0%20.2435-.2187.4583-.4666.4583h-23.33337c-.24791%200-.46666-.2148-.46666-.4583V4.29167c0-.24349.21875-.45834.46666-.45834h23.33337c.2479%200%20.4666.21485.4666.45834V18.0417zM126%204.29167C126%203.03125%20124.95%202%20123.6667%202h-23.33337C99.05%202%2098%203.03125%2098%204.29167V18.0417c0%201.2604%201.05%202.2916%202.33333%202.2916h10.73337v1.8334h-5.13337c-.2625%200-.46666.2005-.46666.4583v.9167c0%20.2578.20416.4583.46666.4583h12.13337c.2625%200%20.4666-.2005.4666-.4583v-.9167c0-.2578-.2041-.4583-.4666-.4583h-5.1334v-1.8334h10.7334c1.2833%200%202.3333-1.0312%202.3333-2.2916V4.29167zM49.57143%2021.1429c0%20.4687-.38839.8571-.85714.8571s-.85715-.3884-.85715-.8571c0-.4688.3884-.8572.85715-.8572.46875%200%20.85714.3884.85714.8572zM54.7143%2019c0%20.2277-.2009.4286-.4286.4286H43.14286c-.22768%200-.42857-.2009-.42857-.4286V6.14286c0-.22768.20089-.42858.42857-.42858H54.2857c.2277%200%20.4286.2009.4286.42858V19zm1.7143-12.85714C56.4286%204.96429%2055.4643%204%2054.2857%204H43.14286C41.96429%204%2041%204.96428%2041%206.14286V20.7143c0%201.1786.96429%202.1428%202.14286%202.1428H54.2857c1.1786%200%202.1429-.9642%202.1429-2.1428V6.14286zM17.21429%2020.36692c0%20.5893-.48215%201.0714-1.07143%201.0714-.58929%200-1.07143-.4821-1.07143-1.0714%200-.5893.48214-1.0715%201.07143-1.0715.58928%200%201.07143.4822%201.07143%201.0715zm3.10514-2.1429c0%20.2277-.2009.4286-.42858.4286h-7.46228c-.22768%200-.42857-.2009-.42857-.4286V6.93832c0-.22768.20089-.42857.42857-.42857h7.46228c.22768%200%20.42858.20089.42858.42857v11.2857zM17.42857%205.86689c0%20.12054-.09375.21429-.21428.21429h-2.14286c-.12054%200-.21429-.09375-.21429-.21429%200-.12053.09375-.21428.21429-.21428h2.14286c.12053%200%20.21428.09375.21428.21428zm3.85713.78572c0-.9375-.77677-1.71429-1.71427-1.71429h-6.85714c-.9375%200-1.71429.77679-1.71429%201.71429v13.71431c0%20.9375.77679%201.7143%201.71429%201.7143h6.85714c.9375%200%201.71427-.7768%201.71427-1.7143V6.65261zM70.42667%2020.8421H89.5333c1.3347%200%202.4267-.9145%202.4267-2.2895V6.5c0-1.375-1.092-2.5-2.4267-2.5H70.42667C69.092%204%2068%205.125%2068%206.5v12.0526c0%201.375%201.092%202.2895%202.42667%202.2895zM69.94133%206.5c0-.26563.2275-.5.48534-.5H89.5333c.2579%200%20.4854.23437.4854.5v12.0526c0%20.2657-.2275.5-.4854.5H70.42667c-.25784%200-.48534-.2343-.48534-.5V6.5zM67%2022v.9474C67%2023.7755%2067.74533%2024%2069.08%2024h21.84c1.3347%200%202.08-.2245%202.08-1.0526V22H67zm15.7074%201.0973h-5.4807c-.1365%200-.24271-.1094-.24271-.25s.10621-.2759.24271-.2759h5.4807c.1365%200%20.2426.1353.2426.2759%200%20.1406-.1061.25-.2426.25z%27%2F%3E%3C%2Fsvg%3E");
background-size: 400% auto;
background-repeat: no-repeat;
}
.device:after {
display: block;
position: absolute;
content: "Mobile";
width: 5rem;
display: block;
top: 6.4em;
background: #aaa;
text-align: center;
color: #fff;
font-family: sans-serif;
font-size: 0.65em;
line-height: 1.4em;
text-transform: uppercase;
}
.device {
background-position: left top;
outline: 1px red dashed;
}
.device::before{ /* TYPESCALE LABEL */
display: block;
position: absolute;
font-size: .6rem;
width: 5rem;
content: "Typescale";
text-align: center;
height: var(--baseline);
outline: 1px red dashed;
bottom: calc(var(--baseline) * -2);
right: 0;
background: cyan;
}
/* default device-targeting CSS */
.mobile-only{
display: inline;
}
.tablet-only, .laptop-only, .wide-only{
display: none;
}
href="https://gistcdn.githack.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device.css" />
https://gistcdn.githack.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device-tablet.css
https://gist.githubusercontent.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device-laptop.css
https://gistcdn.githack.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device-wide.css
<!-- This goes temporarily in your localhost version during dev -->
<link rel="stylesheet" media="screen" href="https://gistcdn.githack.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device.css" />
<link rel="stylesheet" media="screen and (min-width: 500px)" href="https://gistcdn.githack.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device-tablet.css" />
<link rel="stylesheet" media="screen and (min-width: 767px)" href="https://gistcdn.githack.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device-laptop.css" />
<link rel="stylesheet" media="screen and (min-width: 1100px)" href="https://gistcdn.githack.com/alexmwalker/acf69cf4720af01bb0df9b467828c5d7/raw/2b7bb5c5d70fce197fc16aa198ecf9530d6bdc91/device-wide.css" />