I want to hide a div containing the facebook likebox widget from mobile devices. I tried this but it doesn't work.
div code:
<div id="facebook" class="fb-like-box mobile-hide" data-href="https://www.facebook.com/mypage" data-width="220" data-height="250" data-show-faces="true" data-stream="false" data-header="true"></div>
css code:
@media screen and (min-width: 0px) and (max-width: 720px) {
#facebook { display: none; }
.mobile-hide{ display: none; }
}
What am i doing wrong? It does not work using the id or the class reference.
Once the browser/screen reaches 600pixels then #title_message will become hidden. EDIT: if you are using another CSS for mobile then just add the visibility: hidden; to #title_message . Hope this helps you! That fixed it.
You can hide an element in CSS using the CSS properties display: none or visibility: hidden. display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping the space the same.
If you are working on a fluid grid layout, DW already created the 3 media queries for you. To hide a DIV on phone only apply: #div { display:none; } The trick is,that you have to add this line to tablet #div { display:block; //or inline or anything, how you wish to display it } It works for me, hope it's useful.
Solutions with CSS ¶ To hide an element in a responsive layout, we need to use the CSS display property set to its "none" value along with the @media rule. The content of the second <p> element having a "hidden-mobile" class will be hidden on devices smaller than 767px.
In Bootstrap 3.4.1, we can use the "hidden-xs" class to hide an element on phones. So, in the next example, we demonstrate how a <strong> element will be hidden on extra small devices. In Bootstrap 4, the hidden-* (also visible-*) class does not exist any more.
Learn how to use a few snippets of CSS to show and hide content on any website regardless of how the website was built. See how to use the built in Responsive Layout settings on any Beaver Builder module to show and hide content. Using a combination of CSS and a few Dynamik Website Builder settings you can easily show and hide content.
For some reason (unknown to me) this worked:
<div class="mobile-hide">
<div class="fb-like-box" data-href="https://www.facebook.com/mypage" data-width="220" data-height="250" data-show-faces="true" data-stream="false" data-header="true"></div>
</div>
Make sure your page defines a viewport meta tag.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
For more information on this tag see: Understanding The Viewport Meta Tag.
Try these it works for me.
Example 1:
@media only screen and (max-width: 479px) {
.mobile-hide{ display: block !important; }
}
Example 2:
@media only screen and (max-width: 479px) {
.mobile-hide{ display: none !important; }
}
description link
I personally think your "display" parameter is the wrong one, try using visibility instead. I tested it and it worked for me.
This one should work for you:
@media only screen and (min-device-width: 0px) and (max-device-width: 720px) {div#facebook {visibility:hidden;}}
I think you can even forget about the use of a class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With