-1
<style>
@media screen and (min-width: 0px) and (max-width: 400px) {
  #my-content{ display: none; }  /* show it on large screen */
}
@media screen and (min-width: 401px) and (max-width: 1024px) {
  #my-content{ display: block; }   /* hide it small screens */
}
<style>
<div id="my-content">

This code works but I want to add a button for show/hide this "my-content" on small device. I don't want to show this button in large display. This button only show on small screen. I want to use this code with a bootstrap site.

Kara
  • 6,115
  • 16
  • 50
  • 57
Anik Chakraborty
  • 11
  • 1
  • 1
  • 1

2 Answers2

6

You just did the opposite of what you wanted to. Here is a quick fix:

@media screen and (min-width: 0px) and (max-width: 400px) {
  #my-content{ display: block; }  /* show it on smaller screen */
}
@media screen and (min-width: 401px) and (max-width: 1024px) {
  #my-content{ display: none; }   /* hide it on larger screens */
}
<div id="my-content">
Shows only on screens having max width of 400px. 
Resize your browser's width to see changes
</div>
ihpar
  • 666
  • 4
  • 14
0

Bootstrap already has classes to hide things/make them visible. Check to see if these are in your style sheet. http://getbootstrap.com/css/

.visible-xs-, .visible-sm-, .visible-md-, .visible-lg- .hidden-xs, .hidden-sm, .hidden-md, .hidden-lg

Harley
  • 385
  • 1
  • 2
  • 11