Skip to content

Instantly share code, notes, and snippets.

@leanneromak
Last active February 12, 2016 20:32
Show Gist options
  • Save leanneromak/d9345651b8c47c2521dd to your computer and use it in GitHub Desktop.
Save leanneromak/d9345651b8c47c2521dd to your computer and use it in GitHub Desktop.
hide/show divs on desktop/mobile with CSS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>hide and show</title>
<style type="text/css">
#mobile-only {
display:none;
}
@media screen and (max-width: 980px) {
#desktop-only {
display:none;
}
#mobile-only {
display:block !important;
margin-top:100px;
color:red;
}
}
</style>
</head>
<body>
<div id="mobile-only">
<p> This div will be hidden on desktop and show on mobile.</p>
</div>
<div id="desktop-only">
<p> This div will be hidden on mobile and show on desktop.</p>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment