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
368 views
in Technique[技术] by (71.8m points)

css - How can I hide an HTML element for xs screen with Bootstrap 5?

 <ul class="container">
   <li class="row">
     <div class="col">
       <img width="390" src="#">
       <div>29&nbsp;€</div>
     </div>
     <div class="col d-none d-sm-block">
       <h3>Description</h3>
       <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 
          incididunt ut labore et dolore magna aliqua.</p>
     </div>
     <div class="col">
       <h3>Jamie</h3>
       <button><span>View Item</span></button>
     </div>
   </li>
 </ul>

In the code above, using Bootstrap 5, I need to hide an element for xs screen using .d-none .d-sm-block classes. It's only working using .d-none .d-lg-block to hide for md, sm and xs.

How can I hide the element only for xs screen.

Thank you.

question from:https://stackoverflow.com/questions/65841775/how-can-i-hide-an-html-element-for-xs-screen-with-bootstrap-5

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

1 Reply

0 votes
by (71.8m points)

According to this documentation the following classes should do the trick:

.d-none .d-sm-block

.d-none hides the element on all screens .d-sm-block makes the element visible from sm upwards


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

...