1

I made an announcement div and I want it to disappear when I use the mobile version of the webpage because it occupy to much space when resized for the mobile version. How can I hide a div when the size of the webpage becomes bigger?

for example: mobile web surfing

my code is

body {margin:0;}

.icon-bar {
    width: 100%;
    background-color: #0088B8;
    overflow: auto;
}

.icon-bar a {
    float: left;
    width: 20%;
    text-align: center;
    padding: 12px 0;
    transition: all 0.3s ease;
    color: white;
    font-size: 36px;
}

.icon-bar a:hover {
    background-color: #0073C4;
}

.active {
    background-color: #9b0a0a !important;
}
<div class="icon-bar">
  <a href="./index.php"><i class="fa fa-home"></i></a> 
  <a href="./search.php"><i class="fa fa-search"></i></a> 
  <a href="./news.php"><i class="fa fa-envelope"></i></a> 
  <a href="./search.php?search_id=unanswered"><i class="fa fa-globe"></i></a>
  <a href="#"><i class="fa fa-trash"></i></a> 
</div>
Omar
  • 32,302
  • 9
  • 69
  • 112
Dan Andrei
  • 23
  • 1
  • 7
  • 2
    You can use media queries https://www.w3schools.com/css/css_rwd_mediaqueries.asp – Robert Negreanu Jun 18 '17 at 00:25
  • Possible duplicate of [Div show/hide media query](https://stackoverflow.com/questions/11796297/div-show-hide-media-query) –  Jun 18 '17 at 00:28

1 Answers1

2

Maybe he is new to html and css... Try to use css rules to achieve this, like Robert said media queries. Put in your html head this line:

<meta name="viewport" content="width=device-width, initial-scale=1.0">

And in your css file wirte below your div-rules (lets say your div has the id="test"):

@media only screen and (min-width: 800px) {
    #test {
       display: none;
    }
}

Now the div is hidden when the screen width is larger than e.g. 800px.

Tobias Alt
  • 453
  • 1
  • 3
  • 11