- 列偏移与列嵌套
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <!-- 支持移动设备优先 --> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <!-- 导入CSS文件 --> <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css"> <!-- 引入js --> <!-- bootstrap.js 引入必须依赖 jQuery, jQuery需要自行去下载导入进来 --> <script src="bootstrap/js/jquery-3.4.1.js"></script> <!-- 不引入 jQuery 则会报错 Uncaught Error: Bootstrap's JavaScript requires jQuery --> <script src="bootstrap/js/bootstrap.js"></script> <style> div[class^='col-md'] { border: 1px solid #ccc; } </style> </head> <body> <div class="container"> <h2>默认</h2> <div class="row"> <div class="col-md-2">col-md-2</div> <div class="col-md-3">col-md-3</div> <div class="col-md-4">col-md-4</div> </div> <h2>偏移</h2> <div class="row"> <div class="col-md-2 col-md-offset-1">col-md-2</div> <div class="col-md-3">col-md-3</div> <div class="col-md-4">col-md-4</div> <div class="col-md-2 col-md-offset-2">col-md-2</div> <div class="col-md-3">col-md-3</div> <div class="col-md-4">col-md-4</div> </div> <h2>列嵌套</h2> <div class="row"> <div class="col-md-2">col-md-2</div> <div class="col-md-3">col-md-3</div> <div class="col-md-4"> <div class="row"> <div class="col-md-4">嵌套列</div> <div class="col-md-4">嵌套列</div> <div class="col-md-4">嵌套列</div> <div class="col-md-4">嵌套列</div> </div> </div> </div> </div> </body> </html>
- demo 效果: