grid.html 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <th:block th:include="include :: header('栅格')" />
  5. </head>
  6. <body class="gray-bg">
  7. <div class="wrapper wrapper-content">
  8. <div class="row">
  9. <div class="col-sm-12">
  10. <div class="ibox float-e-margins">
  11. <div class="ibox-title">
  12. <h5>栅格设置</h5>
  13. <div class="ibox-tools">
  14. <a class="collapse-link">
  15. <i class="fa fa-chevron-up"></i>
  16. </a>
  17. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  18. <i class="fa fa-wrench"></i>
  19. </a>
  20. <ul class="dropdown-menu dropdown-user">
  21. <li><a href="#">选项1</a>
  22. </li>
  23. <li><a href="#">选项2</a>
  24. </li>
  25. </ul>
  26. <a class="close-link">
  27. <i class="fa fa-times"></i>
  28. </a>
  29. </div>
  30. </div>
  31. <div class="ibox-content">
  32. <p>通过下表可以详细查看 Bootstrap 的栅格系统是如何在多种屏幕设备上工作的。</p>
  33. <div class="table-responsive">
  34. <table class="table table-bordered table-striped">
  35. <thead>
  36. <tr>
  37. <th></th>
  38. <th>
  39. 超小屏幕
  40. <small>手机 (&lt;768px)</small>
  41. </th>
  42. <th>
  43. 小屏幕
  44. <small>平板 (≥768px)</small>
  45. </th>
  46. <th>
  47. 中等屏幕
  48. <small>桌面显示器 (≥992px)</small>
  49. </th>
  50. <th>
  51. 大屏幕
  52. <small>大桌面显示器 (≥1200px)</small>
  53. </th>
  54. </tr>
  55. </thead>
  56. <tbody>
  57. <tr>
  58. <th class="text-nowrap">栅格系统行为</th>
  59. <td>总是水平排列</td>
  60. <td colspan="3">开始是堆叠在一起的,当大于这些阈值时将变为水平排列C</td>
  61. </tr>
  62. <tr>
  63. <th class="text-nowrap"><code>.container</code> 最大宽度</th>
  64. <td>None (自动)</td>
  65. <td>750px</td>
  66. <td>970px</td>
  67. <td>1170px</td>
  68. </tr>
  69. <tr>
  70. <th class="text-nowrap">类前缀</th>
  71. <td><code>.col-xs-</code>
  72. </td>
  73. <td><code>.col-sm-</code>
  74. </td>
  75. <td><code>.col-md-</code>
  76. </td>
  77. <td><code>.col-lg-</code>
  78. </td>
  79. </tr>
  80. <tr>
  81. <th class="text-nowrap">列(column)数</th>
  82. <td colspan="4">12</td>
  83. </tr>
  84. <tr>
  85. <th class="text-nowrap">最大列(column)宽</th>
  86. <td class="text-muted">自动</td>
  87. <td>~62px</td>
  88. <td>~81px</td>
  89. <td>~97px</td>
  90. </tr>
  91. <tr>
  92. <th class="text-nowrap">槽(gutter)宽</th>
  93. <td colspan="4">30px (每列左右均有 15px)</td>
  94. </tr>
  95. <tr>
  96. <th class="text-nowrap">可嵌套</th>
  97. <td colspan="4">是</td>
  98. </tr>
  99. <tr>
  100. <th class="text-nowrap">偏移(Offsets)</th>
  101. <td colspan="4">是</td>
  102. </tr>
  103. <tr>
  104. <th class="text-nowrap">列排序</th>
  105. <td colspan="4">是</td>
  106. </tr>
  107. </tbody>
  108. </table>
  109. </div>
  110. </div>
  111. </div>
  112. </div>
  113. </div>
  114. <div class="row">
  115. <div class="col-sm-12">
  116. <div class="ibox float-e-margins">
  117. <div class="ibox-title">
  118. <h5>从堆叠到水平排列</h5>
  119. <div class="ibox-tools">
  120. <a class="collapse-link">
  121. <i class="fa fa-chevron-up"></i>
  122. </a>
  123. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  124. <i class="fa fa-wrench"></i>
  125. </a>
  126. <ul class="dropdown-menu dropdown-user">
  127. <li><a href="#">选项1</a>
  128. </li>
  129. <li><a href="#">选项2</a>
  130. </li>
  131. </ul>
  132. <a class="close-link">
  133. <i class="fa fa-times"></i>
  134. </a>
  135. </div>
  136. </div>
  137. <div class="ibox-content">
  138. <p>使用单一的一组 <code>.col-md-*</code> 栅格类,就可以创建一个基本的栅格系统,在手机和平板设备上一开始是堆叠在一起的(超小屏幕到小屏幕这一范围),在桌面(中等)屏幕设备上变为水平排列。所有“列(column)必须放在 ” <code>.row</code> 内。</p>
  139. <div class="row show-grid">
  140. <div class="col-md-1">.col-md-1</div>
  141. <div class="col-md-1">.col-md-1</div>
  142. <div class="col-md-1">.col-md-1</div>
  143. <div class="col-md-1">.col-md-1</div>
  144. <div class="col-md-1">.col-md-1</div>
  145. <div class="col-md-1">.col-md-1</div>
  146. <div class="col-md-1">.col-md-1</div>
  147. <div class="col-md-1">.col-md-1</div>
  148. <div class="col-md-1">.col-md-1</div>
  149. <div class="col-md-1">.col-md-1</div>
  150. <div class="col-md-1">.col-md-1</div>
  151. <div class="col-md-1">.col-md-1</div>
  152. </div>
  153. <div class="row show-grid">
  154. <div class="col-md-8">.col-md-8</div>
  155. <div class="col-md-4">.col-md-4</div>
  156. </div>
  157. <div class="row show-grid">
  158. <div class="col-md-4">.col-md-4</div>
  159. <div class="col-md-4">.col-md-4</div>
  160. <div class="col-md-4">.col-md-4</div>
  161. </div>
  162. <div class="row show-grid">
  163. <div class="col-md-6">.col-md-6</div>
  164. <div class="col-md-6">.col-md-6</div>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </div>
  170. <div class="row">
  171. <div class="col-sm-12">
  172. <div class="ibox float-e-margins">
  173. <div class="ibox-title">
  174. <h5>移动设备和桌面屏幕</h5>
  175. <div class="ibox-tools">
  176. <a class="collapse-link">
  177. <i class="fa fa-chevron-up"></i>
  178. </a>
  179. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  180. <i class="fa fa-wrench"></i>
  181. </a>
  182. <ul class="dropdown-menu dropdown-user">
  183. <li><a href="#">选项1</a>
  184. </li>
  185. <li><a href="#">选项2</a>
  186. </li>
  187. </ul>
  188. <a class="close-link">
  189. <i class="fa fa-times"></i>
  190. </a>
  191. </div>
  192. </div>
  193. <div class="ibox-content">
  194. <p>是否不希望在小屏幕设备上所有列都堆叠在一起?那就使用针对超小屏幕和中等屏幕设备所定义的类吧,即 <code>.col-xs-*</code> 和 <code>.col-md-*</code>。请看下面的实例,研究一下这些是如何工作的。</p>
  195. <div class="row show-grid">
  196. <div class="col-xs-12 col-md-8">.col-xs-12 .col-md-8</div>
  197. <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  198. </div>
  199. <div class="row show-grid">
  200. <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  201. <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  202. <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  203. </div>
  204. <div class="row show-grid">
  205. <div class="col-xs-6">.col-xs-6</div>
  206. <div class="col-xs-6">.col-xs-6</div>
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. <div class="row">
  213. <div class="col-sm-12">
  214. <div class="ibox float-e-margins">
  215. <div class="ibox-title">
  216. <h5>手机、平板、桌面</h5>
  217. <div class="ibox-tools">
  218. <a class="collapse-link">
  219. <i class="fa fa-chevron-up"></i>
  220. </a>
  221. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  222. <i class="fa fa-wrench"></i>
  223. </a>
  224. <ul class="dropdown-menu dropdown-user">
  225. <li><a href="#">选项1</a>
  226. </li>
  227. <li><a href="#">选项2</a>
  228. </li>
  229. </ul>
  230. <a class="close-link">
  231. <i class="fa fa-times"></i>
  232. </a>
  233. </div>
  234. </div>
  235. <div class="ibox-content">
  236. <p>在上面案例的基础上,通过使用针对平板设备的 <code>.col-sm-*</code> 类,我们来创建更加动态和强大的布局吧。</p>
  237. <div class="row show-grid">
  238. <div class="col-xs-12 col-sm-6 col-md-8">.col-xs-12 .col-sm-6 .col-md-8</div>
  239. <div class="col-xs-6 col-md-4">.col-xs-6 .col-md-4</div>
  240. </div>
  241. <div class="row show-grid">
  242. <div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
  243. <div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
  244. <!-- Optional: clear the XS cols if their content doesn't match in height -->
  245. <div class="clearfix visible-xs"></div>
  246. <div class="col-xs-6 col-sm-4">.col-xs-6 .col-sm-4</div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </div>
  252. <div class="row">
  253. <div class="col-sm-12">
  254. <div class="ibox float-e-margins">
  255. <div class="ibox-title">
  256. <h5>多余的列(column)将另起一行排列</h5>
  257. <div class="ibox-tools">
  258. <a class="collapse-link">
  259. <i class="fa fa-chevron-up"></i>
  260. </a>
  261. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  262. <i class="fa fa-wrench"></i>
  263. </a>
  264. <ul class="dropdown-menu dropdown-user">
  265. <li><a href="#">选项1</a>
  266. </li>
  267. <li><a href="#">选项2</a>
  268. </li>
  269. </ul>
  270. <a class="close-link">
  271. <i class="fa fa-times"></i>
  272. </a>
  273. </div>
  274. </div>
  275. <div class="ibox-content">
  276. <p>在等宽的4网格中,网格不等高会碰到问题,为了解决这个问题,可使用<code>.clearfix</code>。<a href="#responsive-utilities">响应实用工具类</a>
  277. </p>
  278. <div class="row show-grid">
  279. <div class="col-xs-6 col-sm-3">
  280. .col-xs-6 .col-sm-3
  281. <br>调整窗口大小或者在手机上查看本示例
  282. </div>
  283. <div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
  284. <!-- Add the extra clearfix for only the required viewport -->
  285. <div class="clearfix visible-xs"></div>
  286. <div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
  287. <div class="col-xs-6 col-sm-3">.col-xs-6 .col-sm-3</div>
  288. </div>
  289. </div>
  290. </div>
  291. </div>
  292. </div>
  293. <div class="row">
  294. <div class="col-sm-12">
  295. <div class="ibox float-e-margins">
  296. <div class="ibox-title">
  297. <h5>列偏移</h5>
  298. <div class="ibox-tools">
  299. <a class="collapse-link">
  300. <i class="fa fa-chevron-up"></i>
  301. </a>
  302. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  303. <i class="fa fa-wrench"></i>
  304. </a>
  305. <ul class="dropdown-menu dropdown-user">
  306. <li><a href="#">选项1</a>
  307. </li>
  308. <li><a href="#">选项2</a>
  309. </li>
  310. </ul>
  311. <a class="close-link">
  312. <i class="fa fa-times"></i>
  313. </a>
  314. </div>
  315. </div>
  316. <div class="ibox-content">
  317. <p>使用 <code>.col-md-offset-*</code> 类可以将列向右侧偏移。这些类实际是通过使用 <code>*</code> 选择器为当前元素增加了左侧的边距(margin)。例如,<code>.col-md-offset-4</code> 类将 <code>.col-md-4</code> 元素向右侧偏移了4个列(column)的宽度。</p>
  318. <div class="row show-grid">
  319. <div class="col-md-4">.col-md-4</div>
  320. <div class="col-md-4 col-md-offset-4">.col-md-4 .col-md-offset-4</div>
  321. </div>
  322. <div class="row show-grid">
  323. <div class="col-md-3 col-md-offset-3">.col-md-3 .col-md-offset-3</div>
  324. <div class="col-md-3 col-md-offset-3">.col-md-3 .col-md-offset-3</div>
  325. </div>
  326. <div class="row show-grid">
  327. <div class="col-md-6 col-md-offset-3">.col-md-6 .col-md-offset-3</div>
  328. </div>
  329. </div>
  330. </div>
  331. </div>
  332. </div>
  333. <div class="row">
  334. <div class="col-sm-12">
  335. <div class="ibox float-e-margins">
  336. <div class="ibox-title">
  337. <h5>嵌套列</h5>
  338. <div class="ibox-tools">
  339. <a class="collapse-link">
  340. <i class="fa fa-chevron-up"></i>
  341. </a>
  342. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  343. <i class="fa fa-wrench"></i>
  344. </a>
  345. <ul class="dropdown-menu dropdown-user">
  346. <li><a href="#">选项1</a>
  347. </li>
  348. <li><a href="#">选项2</a>
  349. </li>
  350. </ul>
  351. <a class="close-link">
  352. <i class="fa fa-times"></i>
  353. </a>
  354. </div>
  355. </div>
  356. <div class="ibox-content">
  357. <p>为了使用内置的栅格系统将内容再次嵌套,可以通过添加一个新的 <code>.row</code> 元素和一系列 <code>.col-sm-*</code> 元素到已经存在的 <code>.col-sm-*</code> 元素内。被嵌套的行(row)所包含的列(column)的个数不能超过12(其实,没有要求你必须占满12列)。</p>
  358. <div class="row show-grid">
  359. <div class="col-md-9">
  360. 第一级: .col-md-9
  361. <div class="row show-grid">
  362. <div class="col-md-6">
  363. 第二级: .col-md-6
  364. </div>
  365. <div class="col-md-6">
  366. 第二级: .col-md-6
  367. </div>
  368. </div>
  369. </div>
  370. </div>
  371. </div>
  372. </div>
  373. </div>
  374. </div>
  375. <div class="row">
  376. <div class="col-sm-12">
  377. <div class="ibox float-e-margins">
  378. <div class="ibox-title">
  379. <h5>列排序</h5>
  380. <div class="ibox-tools">
  381. <a class="collapse-link">
  382. <i class="fa fa-chevron-up"></i>
  383. </a>
  384. <a class="dropdown-toggle" data-toggle="dropdown" href="#">
  385. <i class="fa fa-wrench"></i>
  386. </a>
  387. <ul class="dropdown-menu dropdown-user">
  388. <li><a href="#">选项1</a>
  389. </li>
  390. <li><a href="#">选项2</a>
  391. </li>
  392. </ul>
  393. <a class="close-link">
  394. <i class="fa fa-times"></i>
  395. </a>
  396. </div>
  397. </div>
  398. <div class="ibox-content">
  399. <p>通过使用 <code>.col-md-push-*</code> 和 <code>.col-md-pull-*</code> 类就可以很容易的改变列(column)的顺序。</p>
  400. <div class="row show-grid">
  401. <div class="col-md-9 col-md-push-3">.col-md-9 .col-md-push-3</div>
  402. <div class="col-md-3 col-md-pull-9">.col-md-3 .col-md-pull-9</div>
  403. </div>
  404. </div>
  405. </div>
  406. </div>
  407. </div>
  408. </div>
  409. <th:block th:include="include :: footer" />
  410. </body>
  411. </html>