Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove element for certain screen sizes

I am currently creating a responsive web design using media queries. For mobile devices I want to remove my JS slider and replace it with something else. I have looked at .remove() and a few other things from the JQuery library, however these have to be implemented into the HTML and I cannot think of a work around from the css angle.

like image 700
sam_7_h Avatar asked Jul 20 '13 12:07

sam_7_h


People also ask

How do I hide the elements on my small screen?

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.

How do I delete an element in media query?

In the media query I then set no-mobile to display: none;. Show activity on this post. You can also use jquery function addClass() and removeClass() or removeAttr() to fulfill your purpose.

What are media query breakpoints?

Essentially, media query breakpoints are pixel values that a developer/designer can define in CSS. When a responsive website reaches those pixel values, a transformation (such as the one detailed above) occurs so that the website offers an optimal user experience.


3 Answers

Do you need to remove them, or just hide them? If just hiding is okay, then you can combine media queries with display:none:

#mySlider{
    display: block;
}

@media (max-width: 640px) 
{
    #mySlider
    {
        display: none;
    }
}
like image 100
Daniel Gimenez Avatar answered Nov 02 '22 18:11

Daniel Gimenez


You can hide an element and show another depending on screen size using media query from css , this is from one of my live projects (I use this to show/hide icon)

@media only screen and (max-width: 767px) and (min-width: 480px)
{
    .icon-12{ display:none; } // 12 px
    .icon-9{ display:inline-block; }  // 9px
}
like image 42
The Alpha Avatar answered Nov 02 '22 18:11

The Alpha


Not a 100% sure what you mean. But I created a class "no-mobile" that I add to elements that should not be shown on mobile devices. In the media query I then set no-mobile to display: none;.

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

        .nomobile {
            display:none;
        }
}
like image 23
user2515479 Avatar answered Nov 02 '22 16:11

user2515479