Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

hide div tag on mobile view only?

I'm creating a fluid layout for a site. I'm trying to hide the contents of a <div> or the whole <div> itself in the mobile view, but not the tablet and desktop view.

Here's what I've got so far...

#title_message {     clear: both;     float: left;     margin: 10px auto 5px 20px;     width: 28%;     display: none; } 

I have the display set to 'none' for the mobile layout and set as block on the tablet/desktop layouts... Is there an easier way to do that, or is that it?

like image 271
KoldTurkee Avatar asked May 14 '13 18:05

KoldTurkee


People also ask

How do I hide elements in mobile view?

– Display: None It will hide the elements from everything, users and screen readers alike. Also, its descendants are not shown at all.

How do I hide a div tag?

To hide an element, set the style display property to “none”. document. getElementById("element").

How do you hide text messages on a phone?

The most simple way to hide text messages on your Android phone is by securing it with a password, fingerprint, PIN or lock pattern. If someone can't get past the lock screen they can't access your text messages.


1 Answers

You will need two things. The first is @media screen to activate the specific code at a certain screen size, used for responsive design. The second is the use of the visibility: hidden attribute. Once the browser/screen reaches 600pixels then #title_message will become hidden.

@media screen and (max-width: 600px) {   #title_message {     visibility: hidden;     clear: both;     float: left;     margin: 10px auto 5px 20px;     width: 28%;     display: none;   } } 

EDIT: if you are using another CSS for mobile then just add the visibility: hidden; to #title_message. Hope this helps you!

like image 113
Matt Avatar answered Sep 21 '22 04:09

Matt