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.
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 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.
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.
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;
}
}
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
}
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;
}
}
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