codecamp

Bootstrap 实用类

我们可以使用以下类来启用屏幕尺寸落在特定范围内的设备上的元素的可见性。

.visible-*-*类有三种变体,每个CSS显示属性值一个:inline,block和inline-block。

描述
.visible-xs-* 使元素只在屏幕宽度小于768px的超小型设备上可见,在其他上隐藏。
.visible-sm-* 使元素仅在屏幕宽度大于或等于 768px 但小于992px的小型设备上可见,在其他上隐藏。
.visible-md-* 使元素仅在屏幕宽度大于或等于992px 但小于1200px的中型设备上可见,在其他上隐藏。
.visible-lg-* 使元素仅在屏幕宽度大于或等于1200px的大型设备上可见,在其他上隐藏。.

我们可以混合上述类,使元素在多个设备上可见。

我们可以对任何元素应用类 .visible-xs-* .visible-md-*,使其在超小型和中型设备上可见。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<style type="text/css">
    p{
        padding: 10px;
        background: #EEEEEE;
    }
    .bs-example{
      margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-example">
    <p class="visible-xs">
    This paragraph is visible only on <strong>Extra Small Devices</strong> 
    that has screen width less than <code>768px</code>.</p>
    <p class="visible-sm">
    This paragraph is visible only on <strong>Small Devices</strong> 
    that has screen width greater than equal to <code>768px</code> but less than <code>992px</code>.</p>
    <p class="visible-md">This paragraph is visible only on <strong>Medium Devices</strong> 
    that has screen width greater than or equal to <code>992px</code> but 
    less than <code>1200px</code>.</p>
    <p class="visible-lg">This paragraph is visible only on <strong>Large Devices</strong> that 
    has screen width greater than or equal to <code>1200px</code>.</p>
</div>
</body>
</html>

hidden类

我们可以使用以下hidden类来隐藏某些设备上的元素。

描述 描述
.hidden-xs 仅在屏幕宽度小于768px的超小型设备上隐藏元素,在其他上可见。
.hidden-sm 仅在屏幕宽度大于或等于768px但小于992px的小型设备上隐藏元素,在其他上可见。
.hidden-md 仅在屏幕宽度大于或等于992px但小于1200px中型设备上隐藏元素,在其他上可见。
.hidden-lg 仅在屏幕宽度大于或等于1200px的大型设备上隐藏元素,在其他上可见。

我们可以混合上面的类,使元素在多个设备上隐藏。

我们可以在任何元素上应用类 .hidden-xs .hidden-md,使其在超小型和中小型设备上隐藏。

<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<style type="text/css">
    p{
        padding: 20px;
        background: #E6E6FA;
        border-radius: 5px;
    }
    .bs-example{
      margin: 20px;
    }
</style>
</head>
<body>
<div class="bs-example">
    <p class="hidden-xs">This paragraph is hidden only on <strong>Extra Small Devices</strong> that 
    has screen width less than <code>768px</code>.</p>
    <p class="hidden-sm">This paragraph is hidden only on <strong>Small Devices</strong> that has 
    screen width greater than equal to <code>768px</code> but less than <code>992px</code>.</p>
    <p class="hidden-md">This paragraph is hidden only on <strong>Medium Devices</strong> that has 
    screen width greater than or equal to <code>992px</code> but less than <code>1200px</code>.</p>
    <p class="hidden-lg">This paragraph is hidden only on <strong>Large Devices</strong> that has 
    screen width greater than or equal to <code>1200px</code>.</p>
</div>
</body>
</html>

显示/隐藏打印

我们可以使用以下实用类来显示或隐藏某些元素用于打印目的。

描述 描述
.visible-print-block 隐藏浏览器呈现的块元素,打印时可见。
.visible-print-inline 隐藏浏览器呈现的内嵌元素,打印时可见。
.visible-print-inline-block 隐藏浏览器呈现的inline-block元素,打印时可见。
.hidden-print 在浏览器上显示的元素,打印时隐藏。
Bootstrap 动态布局
Bootstrap 按钮
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Bootstrap 介绍

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }