Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

html - how to hide div in mobile devices using boostrap?

I want to hide below div in all mobile devices

<div class="right-col pull-right">
</div>

and I have tried following suggestions already but nothing works: Missing visible-** and hidden-** in Bootstrap v4 Hiding elements in responsive layout?

any one suggest me how can i hide above div using bootstrap? My website url: https://www.smartdirection.co/

Myboostrap version:

<link rel='stylesheet' id='bootstrap-css'  href='https://www.smartdirection.co/wp-content/themes/pickton/css/bootstrap.css?ver=5.6' type='text/css' media='all' />

any help would be appreciated.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Using JavaScript will not work if it is disabled in the user’s browser. This method will also still work in testing, since user agent sniffing is highly unreliable.

Use a CSS media query:

@media only screen and (max-width: 770px) {
    .right-col.pull-right {
        display: none;
    }
}

To hide this particular div only, give it another class of your own, like this:

<div class="mobile-hidden right-col pull-right">
</div>

And change the CSS to:

@media only screen and (max-width: 770px) {
    .mobile-hidden {
        display: none;
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...