4

I had a hard time to fix it. Maybe I am just very noob on css. Basically, I want the icon to visible only in Mobile version of the site.

in above 767px I put this code to make i hidden. .neighbourhood-img img {display:none;}

My question is, how can I make it visible in below 767px width..

Thanks!

Abs Duls
  • 69
  • 1
  • 1
  • 2

5 Answers5

3

hey check out this css

@media screen and (min-width: 768px) {
    .neighbourhood-img img {display:none;}
}

@media screen and (max-width: 767px) {

        .neighbourhood-img img {display:block;}

}
Soundhar Raj
  • 623
  • 3
  • 12
  • 26
  • I think the second `media querie` is not necessary; The `display:none` style only appear when the specified condition is met. Aren't you agree? – tomloprod May 23 '15 at 07:28
2

What you need is called media queries. Try with:

@media screen and (min-width: 768px) {
    .neighbourhood-img img {display:none;}
}

It will be hidden when the width of the screen is at least 768px

You can read more about media queries here:

https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Media_queries

tomloprod
  • 7,472
  • 6
  • 48
  • 66
1

You can use media queries available in CSS to define the styles which meet certain conditions, in you case the condition will be screen width.

Vikash Kesarwani
  • 850
  • 5
  • 14
0

Use Css Class:

.neighbourhood-img img 
{
display:block;
}
Sagar
  • 642
  • 3
  • 14
0

I think I understand what you're asking. If you only want it to visible on mobile version then you could do the following:

Make a new CSS rule:

@media only screen and (max-width: 767px) {
    .m-show {
        display: block !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

Then wrap your icon in a div tag as below, with the styling to hide it (but make its class the m-show class):

<div style="display: none; max-height: 0; overflow: hidden" class="m-show">
Your hidden content here...
</div>

This will hide it if it isn't in that max width of 767, otherwise it will show it. Hope this makes sense. I would also suggest making that inline styling in the div tag a separate CSS class (just because I don't like inline styling).

adrian
  • 2,786
  • 2
  • 18
  • 33
  • @tomloprod Do you mind me asking why not? -- Edit: I also see the upvoted answer makes more sense – adrian May 23 '15 at 07:32