why bootstrap class d-sm-none still displays image in small screen

别来无恙 提交于 2021-01-29 08:44:57

问题


I desire a row with 2 columns by using bootstrap4: 1st column takes size 9 in all viewports 2nd column takes size 3 in lg and md but disappears in sm viewport.

I tried the following with d-none/d-sm-none but it does not work as expected

      <div class="container">
        <div class="row">
          <div class="col-lg-9 col-md-9">
              <h1>Col-1: MD-9 or LG-9</h1>
          </div>
          <div class="col-lg-3 col-md-3 d-sm-none">
            <h1>Col-2: MD-3, LG-3, SM NONE</h1>
          </div>
          </div>
        </div>

d-none disappears 2nd column regardless the viewport size d-sm-none disappears 2nd column at lg and md but appear in sm..

here is the codepen Thanks.


回答1:


ok, I found the answer.

d-*-none/d-none is for hiding the element in the column, not the columns itself.. so the answer is

  <div class="container">
        <div class="row">
          <div class="col-lg-9 col-md-9">
              <h1>Col-1: MD-9 or LG-9</h1>
          </div>
          <div class="col-lg-3 col-md-3">
            <h1 class="d-sm-none d-md-block">Col-2: MD-3, LG-3, SM NONE</h1>
          </div>
          </div>
        </div>

Thanks.



来源:https://stackoverflow.com/questions/59299836/why-bootstrap-class-d-sm-none-still-displays-image-in-small-screen

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!