Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Bootstrap -- mobile-friendly layout


May 30, 2021 Article blog



Bootstrap has several useful classes for developing mobile-friendly layouts.

.visible-phone: Visible on phones with widths of 767px and below, hidden invisible on tablets from 979px to 768px, invisible on desktop, which is tacit.

.visible-tablet: Hide invisible on phones with widths of 767px and below, visible on tablets from 979px to 768px, and invisible on desktops, which is tacit.

.visible-desktop: Hide invisible on phones with widths of 767px and below, invisible on tablets from 979px to 768px, and visible on desktops, which is tacit.

.hidden-phone: Hide invisible on phones with widths of 767px and below, visible on tablets from 979px to 768px, and visible on desktops, with acquiescence.

.hidden-tablet: Visible on phones with widths of 767px and below, hidden from 979px to 768px tablets, visible on desktops, which is tacit.

.hidden-desktop: Visible on phones with widths of 767px and below, on tablets from 979px to 768px, hidden from the desktop, which is tacit.

Let's go straight to the code:

<!doctype html> 
<html> 
<head> 
<meta charset="utf⑻"> 
<meta name="viewport" content="width=device-width, initial-scale=1.0"> 
<title>响应式布局的实用类</title> 
<link href="../bootstrap/css/bootstrap.css" rel="stylesheet"> 
<link href="../bootstrap/css/bootstrap-responsive.css" rel="stylesheet"> <!--[if lt IE 9]> 
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> 
</head> 
<body> 
<div class="container"> 
<h1 class="page-header">响应式布局的实用类
<small> 使用Bootstrap网格系统布局网页</small></h1> 
<div class="row"> 
<div class="page-header clearfix"> 
<div class="span4">
<img src="images/phone.png" alt="智能手机"></div> 
<div class="span4 hidden-phone">
<img src="images/tablet.png" alt="平板电脑"></div> 
<div class="span4"><img src="images/desktop.png" alt="桌面电脑"></div> 
</div> </div> </div> 
<script src="../bootstrap/js/jquery⑴.7.2.min.js"></script> 
<script src="../bootstrap/js/bootstrap.js"></script> 
</body> 
</html>