bootstrap 4中的自适应显示
Bootstrap4中响应式常用的CSS类,由于Bootstrap4移除了前版本用来控制显示的.hidden-*
和visible-*
CSS类,取而代之的是.d-*-none
和.d-*-block
,比如你原来使用的是class="hidden-xs"
在最新的4版中应该写成class="d-none d-sm-block"
(或者 d-none
d-sm-inline-block
) ...
一些实用的示例:
<div class="d-none d-sm-block"> hidden-xs <div class="d-none d-md-block"> visible-md and up (hidden-sm and down) <div class="d-none d-lg-block"> visible-lg and up (hidden-md and down) <div class="d-none d-xl-block"> visible-xl </div> </div> </div> </div> <div class="d-sm-none"> eXtra Small <576px </div> <div class="d-none d-sm-block d-md-none d-lg-none d-xl-none"> SMall ≥576px </div> <div class="d-none d-md-block d-lg-none d-xl-none"> MeDium ≥768px </div> <div class="d-none d-lg-block d-xl-none"> LarGe ≥992px </div> <div class="d-none d-xl-block"> eXtra Large ≥1200px </div> <div class="d-xl-none"> hidden-xl (visible-lg and down) <div class="d-lg-none d-xl-none"> visible-md and down (hidden-lg and up) <div class="d-md-none d-lg-none d-xl-none"> visible-sm and down (or hidden-md and up) <div class="d-sm-none"> visible-xs </div> </div> </div> </div>