25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

464 lines
12 KiB

  1. <div class="bs-docs-section">
  2. <h1 id="tables" class="page-header">Tables</h1>
  3. <h2 id="tables-example">Basic example</h2>
  4. <p>For basic styling&mdash;light padding and only horizontal dividers&mdash;add the base class <code>.table</code> to any <code>&lt;table&gt;</code>. It may seem super redundant, but given the widespread use of tables for other plugins like calendars and date pickers, we've opted to isolate our custom table styles.</p>
  5. <div class="bs-example">
  6. <table class="table">
  7. <caption>Optional table caption.</caption>
  8. <thead>
  9. <tr>
  10. <th>#</th>
  11. <th>First Name</th>
  12. <th>Last Name</th>
  13. <th>Username</th>
  14. </tr>
  15. </thead>
  16. <tbody>
  17. <tr>
  18. <td>1</td>
  19. <td>Mark</td>
  20. <td>Otto</td>
  21. <td>@mdo</td>
  22. </tr>
  23. <tr>
  24. <td>2</td>
  25. <td>Jacob</td>
  26. <td>Thornton</td>
  27. <td>@fat</td>
  28. </tr>
  29. <tr>
  30. <td>3</td>
  31. <td>Larry</td>
  32. <td>the Bird</td>
  33. <td>@twitter</td>
  34. </tr>
  35. </tbody>
  36. </table>
  37. </div><!-- /example -->
  38. {% highlight html %}
  39. <table class="table">
  40. ...
  41. </table>
  42. {% endhighlight %}
  43. <h2 id="tables-striped">Striped rows</h2>
  44. <p>Use <code>.table-striped</code> to add zebra-striping to any table row within the <code>&lt;tbody&gt;</code>.</p>
  45. <div class="bs-callout bs-callout-danger">
  46. <h4>Cross-browser compatibility</h4>
  47. <p>Striped tables are styled via the <code>:nth-child</code> CSS selector, which is not available in Internet Explorer 8.</p>
  48. </div>
  49. <div class="bs-example">
  50. <table class="table table-striped">
  51. <thead>
  52. <tr>
  53. <th>#</th>
  54. <th>First Name</th>
  55. <th>Last Name</th>
  56. <th>Username</th>
  57. </tr>
  58. </thead>
  59. <tbody>
  60. <tr>
  61. <td>1</td>
  62. <td>Mark</td>
  63. <td>Otto</td>
  64. <td>@mdo</td>
  65. </tr>
  66. <tr>
  67. <td>2</td>
  68. <td>Jacob</td>
  69. <td>Thornton</td>
  70. <td>@fat</td>
  71. </tr>
  72. <tr>
  73. <td>3</td>
  74. <td>Larry</td>
  75. <td>the Bird</td>
  76. <td>@twitter</td>
  77. </tr>
  78. </tbody>
  79. </table>
  80. </div><!-- /example -->
  81. {% highlight html %}
  82. <table class="table table-striped">
  83. ...
  84. </table>
  85. {% endhighlight %}
  86. <h2 id="tables-bordered">Bordered table</h2>
  87. <p>Add <code>.table-bordered</code> for borders on all sides of the table and cells.</p>
  88. <div class="bs-example">
  89. <table class="table table-bordered">
  90. <thead>
  91. <tr>
  92. <th>#</th>
  93. <th>First Name</th>
  94. <th>Last Name</th>
  95. <th>Username</th>
  96. </tr>
  97. </thead>
  98. <tbody>
  99. <tr>
  100. <td rowspan="2">1</td>
  101. <td>Mark</td>
  102. <td>Otto</td>
  103. <td>@mdo</td>
  104. </tr>
  105. <tr>
  106. <td>Mark</td>
  107. <td>Otto</td>
  108. <td>@TwBootstrap</td>
  109. </tr>
  110. <tr>
  111. <td>2</td>
  112. <td>Jacob</td>
  113. <td>Thornton</td>
  114. <td>@fat</td>
  115. </tr>
  116. <tr>
  117. <td>3</td>
  118. <td colspan="2">Larry the Bird</td>
  119. <td>@twitter</td>
  120. </tr>
  121. </tbody>
  122. </table>
  123. </div><!-- /example -->
  124. {% highlight html %}
  125. <table class="table table-bordered">
  126. ...
  127. </table>
  128. {% endhighlight %}
  129. <h2 id="tables-hover-rows">Hover rows</h2>
  130. <p>Add <code>.table-hover</code> to enable a hover state on table rows within a <code>&lt;tbody&gt;</code>.</p>
  131. <div class="bs-example">
  132. <table class="table table-hover">
  133. <thead>
  134. <tr>
  135. <th>#</th>
  136. <th>First Name</th>
  137. <th>Last Name</th>
  138. <th>Username</th>
  139. </tr>
  140. </thead>
  141. <tbody>
  142. <tr>
  143. <td>1</td>
  144. <td>Mark</td>
  145. <td>Otto</td>
  146. <td>@mdo</td>
  147. </tr>
  148. <tr>
  149. <td>2</td>
  150. <td>Jacob</td>
  151. <td>Thornton</td>
  152. <td>@fat</td>
  153. </tr>
  154. <tr>
  155. <td>3</td>
  156. <td colspan="2">Larry the Bird</td>
  157. <td>@twitter</td>
  158. </tr>
  159. </tbody>
  160. </table>
  161. </div><!-- /example -->
  162. {% highlight html %}
  163. <table class="table table-hover">
  164. ...
  165. </table>
  166. {% endhighlight %}
  167. <h2 id="tables-condensed">Condensed table</h2>
  168. <p>Add <code>.table-condensed</code> to make tables more compact by cutting cell padding in half.</p>
  169. <div class="bs-example">
  170. <table class="table table-condensed">
  171. <thead>
  172. <tr>
  173. <th>#</th>
  174. <th>First Name</th>
  175. <th>Last Name</th>
  176. <th>Username</th>
  177. </tr>
  178. </thead>
  179. <tbody>
  180. <tr>
  181. <td>1</td>
  182. <td>Mark</td>
  183. <td>Otto</td>
  184. <td>@mdo</td>
  185. </tr>
  186. <tr>
  187. <td>2</td>
  188. <td>Jacob</td>
  189. <td>Thornton</td>
  190. <td>@fat</td>
  191. </tr>
  192. <tr>
  193. <td>3</td>
  194. <td colspan="2">Larry the Bird</td>
  195. <td>@twitter</td>
  196. </tr>
  197. </tbody>
  198. </table>
  199. </div><!-- /example -->
  200. {% highlight html %}
  201. <table class="table table-condensed">
  202. ...
  203. </table>
  204. {% endhighlight %}
  205. <h2 id="tables-contextual-classes">Contextual classes</h2>
  206. <p>Use contextual classes to color table rows or individual cells.</p>
  207. <div class="table-responsive">
  208. <table class="table table-bordered table-striped">
  209. <colgroup>
  210. <col class="col-xs-1">
  211. <col class="col-xs-7">
  212. </colgroup>
  213. <thead>
  214. <tr>
  215. <th>Class</th>
  216. <th>Description</th>
  217. </tr>
  218. </thead>
  219. <tbody>
  220. <tr>
  221. <td>
  222. <code>.active</code>
  223. </td>
  224. <td>Applies the hover color to a particular row or cell</td>
  225. </tr>
  226. <tr>
  227. <td>
  228. <code>.success</code>
  229. </td>
  230. <td>Indicates a successful or positive action</td>
  231. </tr>
  232. <tr>
  233. <td>
  234. <code>.info</code>
  235. </td>
  236. <td>Indicates a neutral informative change or action</td>
  237. </tr>
  238. <tr>
  239. <td>
  240. <code>.warning</code>
  241. </td>
  242. <td>Indicates a warning that might need attention</td>
  243. </tr>
  244. <tr>
  245. <td>
  246. <code>.danger</code>
  247. </td>
  248. <td>Indicates a dangerous or potentially negative action</td>
  249. </tr>
  250. </tbody>
  251. </table>
  252. </div>
  253. <div class="bs-example">
  254. <table class="table">
  255. <thead>
  256. <tr>
  257. <th>#</th>
  258. <th>Column heading</th>
  259. <th>Column heading</th>
  260. <th>Column heading</th>
  261. </tr>
  262. </thead>
  263. <tbody>
  264. <tr class="active">
  265. <td>1</td>
  266. <td>Column content</td>
  267. <td>Column content</td>
  268. <td>Column content</td>
  269. </tr>
  270. <tr>
  271. <td>2</td>
  272. <td>Column content</td>
  273. <td>Column content</td>
  274. <td>Column content</td>
  275. </tr>
  276. <tr class="success">
  277. <td>3</td>
  278. <td>Column content</td>
  279. <td>Column content</td>
  280. <td>Column content</td>
  281. </tr>
  282. <tr>
  283. <td>4</td>
  284. <td>Column content</td>
  285. <td>Column content</td>
  286. <td>Column content</td>
  287. </tr>
  288. <tr class="info">
  289. <td>5</td>
  290. <td>Column content</td>
  291. <td>Column content</td>
  292. <td>Column content</td>
  293. </tr>
  294. <tr>
  295. <td>6</td>
  296. <td>Column content</td>
  297. <td>Column content</td>
  298. <td>Column content</td>
  299. </tr>
  300. <tr class="warning">
  301. <td>7</td>
  302. <td>Column content</td>
  303. <td>Column content</td>
  304. <td>Column content</td>
  305. </tr>
  306. <tr>
  307. <td>8</td>
  308. <td>Column content</td>
  309. <td>Column content</td>
  310. <td>Column content</td>
  311. </tr>
  312. <tr class="danger">
  313. <td>9</td>
  314. <td>Column content</td>
  315. <td>Column content</td>
  316. <td>Column content</td>
  317. </tr>
  318. </tbody>
  319. </table>
  320. </div><!-- /example -->
  321. {% highlight html %}
  322. <!-- On rows -->
  323. <tr class="active">...</tr>
  324. <tr class="success">...</tr>
  325. <tr class="warning">...</tr>
  326. <tr class="danger">...</tr>
  327. <tr class="info">...</tr>
  328. <!-- On cells (`td` or `th`) -->
  329. <tr>
  330. <td class="active">...</td>
  331. <td class="success">...</td>
  332. <td class="warning">...</td>
  333. <td class="danger">...</td>
  334. <td class="info">...</td>
  335. </tr>
  336. {% endhighlight %}
  337. <h2 id="tables-responsive">Responsive tables</h2>
  338. <p>Create responsive tables by wrapping any <code>.table</code> in <code>.table-responsive</code> to make them scroll horizontally on small devices (under 768px). When viewing on anything larger than 768px wide, you will not see any difference in these tables.</p>
  339. <div class="bs-callout bs-callout-warning">
  340. <h4>Firefox and fieldsets</h4>
  341. <p>Firefox has some awkward fieldset styling involving <code>width</code> that interferes with the responsive table. This cannot be overriden without a Firefox-specific hack that we <strong>don't</strong> provide in Bootstrap:</p>
  342. {% highlight css %}
  343. @-moz-document url-prefix() {
  344. fieldset { display: table-cell; }
  345. }
  346. {% endhighlight %}
  347. <p>For more information, read <a href="http://stackoverflow.com/questions/17408815/fieldset-resizes-wrong-appears-to-have-unremovable-min-width-min-content/17863685#17863685">this Stack Overflow answer</a>.</p>
  348. </div>
  349. <div class="bs-example">
  350. <div class="table-responsive">
  351. <table class="table">
  352. <thead>
  353. <tr>
  354. <th>#</th>
  355. <th>Table heading</th>
  356. <th>Table heading</th>
  357. <th>Table heading</th>
  358. <th>Table heading</th>
  359. <th>Table heading</th>
  360. <th>Table heading</th>
  361. </tr>
  362. </thead>
  363. <tbody>
  364. <tr>
  365. <td>1</td>
  366. <td>Table cell</td>
  367. <td>Table cell</td>
  368. <td>Table cell</td>
  369. <td>Table cell</td>
  370. <td>Table cell</td>
  371. <td>Table cell</td>
  372. </tr>
  373. <tr>
  374. <td>2</td>
  375. <td>Table cell</td>
  376. <td>Table cell</td>
  377. <td>Table cell</td>
  378. <td>Table cell</td>
  379. <td>Table cell</td>
  380. <td>Table cell</td>
  381. </tr>
  382. <tr>
  383. <td>3</td>
  384. <td>Table cell</td>
  385. <td>Table cell</td>
  386. <td>Table cell</td>
  387. <td>Table cell</td>
  388. <td>Table cell</td>
  389. <td>Table cell</td>
  390. </tr>
  391. </tbody>
  392. </table>
  393. </div><!-- /.table-responsive -->
  394. <div class="table-responsive">
  395. <table class="table table-bordered">
  396. <thead>
  397. <tr>
  398. <th>#</th>
  399. <th>Table heading</th>
  400. <th>Table heading</th>
  401. <th>Table heading</th>
  402. <th>Table heading</th>
  403. <th>Table heading</th>
  404. <th>Table heading</th>
  405. </tr>
  406. </thead>
  407. <tbody>
  408. <tr>
  409. <td>1</td>
  410. <td>Table cell</td>
  411. <td>Table cell</td>
  412. <td>Table cell</td>
  413. <td>Table cell</td>
  414. <td>Table cell</td>
  415. <td>Table cell</td>
  416. </tr>
  417. <tr>
  418. <td>2</td>
  419. <td>Table cell</td>
  420. <td>Table cell</td>
  421. <td>Table cell</td>
  422. <td>Table cell</td>
  423. <td>Table cell</td>
  424. <td>Table cell</td>
  425. </tr>
  426. <tr>
  427. <td>3</td>
  428. <td>Table cell</td>
  429. <td>Table cell</td>
  430. <td>Table cell</td>
  431. <td>Table cell</td>
  432. <td>Table cell</td>
  433. <td>Table cell</td>
  434. </tr>
  435. </tbody>
  436. </table>
  437. </div><!-- /.table-responsive -->
  438. </div><!-- /example -->
  439. {% highlight html %}
  440. <div class="table-responsive">
  441. <table class="table">
  442. ...
  443. </table>
  444. </div>
  445. {% endhighlight %}
  446. </div>