76e45884a283530763f65864c5fedaa567b3aaa7.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. ---
  2. layout: docs
  3. title: Cards
  4. group: components
  5. ---
  6. A **card** is a flexible and extensible content container. It includes options for headers and footers, a wide variety of content, contextual background colors, and powerful display options.
  7. If you're familiar with Bootstrap 3, cards replace our old panels, wells, and thumbnails. Similar functionality to those components is available as modifier classes for cards.
  8. ## Contents
  9. * Will be replaced with the ToC, excluding the "Contents" header
  10. {:toc}
  11. ## Example
  12. Cards require a small amount of markup and classes to provide you with as much control as possible. These classes and markup are flexible though and can typically be remixed and extended with ease. For example, if your card has no flush content like images, feel free to put the `.card-block` class on the `.card` element to consolidate your markup.
  13. {% example html %}
  14. <div class="card">
  15. <img class="card-img-top" data-src="holder.js/100%x180/" alt="Card image cap">
  16. <div class="card-block">
  17. <h4 class="card-title">Card title</h4>
  18. <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
  19. <a href="javascript:;" class="btn btn-primary">Button</a>
  20. </div>
  21. </div>
  22. {% endexample %}
  23. ## Content types
  24. Cards support a wide variety of content, including images, text, list groups, links, and more. Mix and match multiple content types to create the card you need.
  25. {% example html %}
  26. <div class="card">
  27. <img class="card-img-top" data-src="holder.js/100%x180/?text=Image cap" alt="Card image cap">
  28. <div class="card-block">
  29. <h4 class="card-title">Card title</h4>
  30. <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
  31. </div>
  32. <ul class="list-group list-group-flush">
  33. <li class="list-group-item">Cras justo odio</li>
  34. <li class="list-group-item">Dapibus ac facilisis in</li>
  35. <li class="list-group-item">Vestibulum at eros</li>
  36. </ul>
  37. <div class="card-block">
  38. <a href="javascript:;" class="card-link">Card link</a>
  39. <a href="javascript:;" class="card-link">Another link</a>
  40. </div>
  41. </div>
  42. {% endexample %}
  43. {% example html %}
  44. <div class="card">
  45. <img class="card-img-top" data-src="holder.js/100%x180/?text=Image cap" alt="Card image cap">
  46. <div class="card-block">
  47. <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
  48. </div>
  49. </div>
  50. {% endexample %}
  51. {% example html %}
  52. <div class="card card-block">
  53. <h4 class="card-title">Card title</h4>
  54. <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
  55. <a href="javascript:;" class="card-link">Card link</a>
  56. <a href="javascript:;" class="card-link">Another link</a>
  57. </div>
  58. {% endexample %}
  59. {% example html %}
  60. <div class="card">
  61. <div class="card-block">
  62. <h4 class="card-title">Card title</h4>
  63. <h6 class="card-subtitle text-muted">Support card subtitle</h6>
  64. </div>
  65. <img data-src="holder.js/100%x180/?text=Image" alt="Card image">
  66. <div class="card-block">
  67. <p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
  68. <a href="javascript:;" class="card-link">Card link</a>
  69. <a href="javascript:;" class="card-link">Another link</a>
  70. </div>
  71. </div>
  72. {% endexample %}
  73. ## Sizing
  74. Cards are block-level by default, so they'll fill the available horizontal space. Constrain their widths via inline styles, our predefined grid classes, or with custom styles using our grid mixins.
  75. Using the grid:
  76. {% example html %}
  77. <div class="row">
  78. <div class="col-sm-6">
  79. <div class="card card-block">
  80. <h3 class="card-title">Special title treatment</h3>
  81. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  82. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  83. </div>
  84. </div>
  85. <div class="col-sm-6">
  86. <div class="card card-block">
  87. <h3 class="card-title">Special title treatment</h3>
  88. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  89. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  90. </div>
  91. </div>
  92. </div>
  93. {% endexample %}
  94. Using custom widths:
  95. {% example html %}
  96. <div class="card card-block" style="width: 20rem;">
  97. <h3 class="card-title">Special title treatment</h3>
  98. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  99. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  100. </div>
  101. {% endexample %}
  102. ## Text alignment
  103. You can quickly change the text alignment of any card—in its entirety or specific parts—with our [text align classes]().
  104. {% example html %}
  105. <div class="card card-block">
  106. <h4 class="card-title">Special title treatment</h4>
  107. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  108. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  109. </div>
  110. <div class="card card-block text-center">
  111. <h4 class="card-title">Special title treatment</h4>
  112. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  113. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  114. </div>
  115. <div class="card card-block text-right">
  116. <h4 class="card-title">Special title treatment</h4>
  117. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  118. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  119. </div>
  120. {% endexample %}
  121. ## Header and footer
  122. Add an optional header and/or footer within a card.
  123. {% example html %}
  124. <div class="card">
  125. <div class="card-header">
  126. Featured
  127. </div>
  128. <div class="card-block">
  129. <h4 class="card-title">Special title treatment</h4>
  130. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  131. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  132. </div>
  133. </div>
  134. {% endexample %}
  135. {% example html %}
  136. <div class="card">
  137. <div class="card-header">
  138. Quote
  139. </div>
  140. <div class="card-block">
  141. <blockquote class="card-blockquote">
  142. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  143. <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
  144. </blockquote>
  145. </div>
  146. </div>
  147. {% endexample %}
  148. {% example html %}
  149. <div class="card text-center">
  150. <div class="card-header">
  151. Featured
  152. </div>
  153. <div class="card-block">
  154. <h4 class="card-title">Special title treatment</h4>
  155. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  156. <a href="javascript:;" class="btn btn-primary">Go somewhere</a>
  157. </div>
  158. <div class="card-footer text-muted">
  159. 2 days ago
  160. </div>
  161. </div>
  162. {% endexample %}
  163. ## Image caps
  164. Similar to headers and footers, cards include top and bottom image caps.
  165. {% example html %}
  166. <div class="card">
  167. <img class="card-img-top" data-src="holder.js/100%x180/" alt="Card image cap">
  168. <div class="card-block">
  169. <h4 class="card-title">Card title</h4>
  170. <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
  171. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  172. </div>
  173. </div>
  174. <div class="card">
  175. <div class="card-block">
  176. <h4 class="card-title">Card title</h4>
  177. <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
  178. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  179. </div>
  180. <img class="card-img-bottom" data-src="holder.js/100%x180/" alt="Card image cap">
  181. </div>
  182. {% endexample %}
  183. ## Image overlays
  184. Turn an image into a card background and overlay your card's text. Depending on the image, you may or may not need `.card-inverse` (see below).
  185. {% example html %}
  186. <div class="card card-inverse">
  187. <img class="card-img" data-src="holder.js/100%x270/#55595c:#373a3c/text:Card image" alt="Card image">
  188. <div class="card-img-overlay">
  189. <h4 class="card-title">Card title</h4>
  190. <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
  191. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  192. </div>
  193. </div>
  194. {% endexample %}
  195. ## Inverted text
  196. Cards include a class for quickly toggling **the text color**. By default, cards use dark text and assume a light background. **Add `.card-inverse` for white text** and specify the `background-color` and `border-color` to go with it.
  197. You can also use `.card-inverse` with the [contextual backgrounds variants](#background-variations).
  198. {% example html %}
  199. <div class="card card-inverse" style="background-color: #333; border-color: #333;">
  200. <div class="card-block">
  201. <h3 class="card-title">Special title treatment</h3>
  202. <p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
  203. <a href="javascript:;" class="btn btn-primary">Button</a>
  204. </div>
  205. </div>
  206. {% endexample %}
  207. ## Background variants
  208. Cards include their own variant classes for quickly changing the `background-color` and `border-color` of a card. **Darker colors require the use of `.card-inverse`.**
  209. {% example html %}
  210. <div class="card card-inverse card-primary text-center">
  211. <div class="card-block">
  212. <blockquote class="card-blockquote">
  213. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  214. <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
  215. </blockquote>
  216. </div>
  217. </div>
  218. <div class="card card-inverse card-success text-center">
  219. <div class="card-block">
  220. <blockquote class="card-blockquote">
  221. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  222. <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
  223. </blockquote>
  224. </div>
  225. </div>
  226. <div class="card card-inverse card-info text-center">
  227. <div class="card-block">
  228. <blockquote class="card-blockquote">
  229. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  230. <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
  231. </blockquote>
  232. </div>
  233. </div>
  234. <div class="card card-inverse card-warning text-center">
  235. <div class="card-block">
  236. <blockquote class="card-blockquote">
  237. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  238. <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
  239. </blockquote>
  240. </div>
  241. </div>
  242. <div class="card card-inverse card-danger text-center">
  243. <div class="card-block">
  244. <blockquote class="card-blockquote">
  245. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  246. <footer>Someone famous in <cite title="Source Title">Source Title</cite></footer>
  247. </blockquote>
  248. </div>
  249. </div>
  250. {% endexample %}
  251. ## Groups
  252. Use card groups to render cards as a single, attached element with equal width and height columns. By default, card groups use `display: table;` and `table-layout: fixed;` to achieve their uniform sizing. However, enabling [flexbox mode](/layout/flexbox) can switch that to use `display: flex;` and provide the same effect.
  253. {% example html %}
  254. <div class="card-group">
  255. <div class="card">
  256. <img class="card-img-top" data-src="holder.js/100%x180/" alt="Card image cap">
  257. <div class="card-block">
  258. <h4 class="card-title">Card title</h4>
  259. <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
  260. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  261. </div>
  262. </div>
  263. <div class="card">
  264. <img class="card-img-top" data-src="holder.js/100%x180/" alt="Card image cap">
  265. <div class="card-block">
  266. <h4 class="card-title">Card title</h4>
  267. <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
  268. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  269. </div>
  270. </div>
  271. <div class="card">
  272. <img class="card-img-top" data-src="holder.js/100%x180/" alt="Card image cap">
  273. <div class="card-block">
  274. <h4 class="card-title">Card title</h4>
  275. <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
  276. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  277. </div>
  278. </div>
  279. </div>
  280. {% endexample %}
  281. ## Decks
  282. Need a set of equal width and height cards that aren't attached to one another? Use card decks. By default, card decks require two wrapping elements: `.card-deck-wrapper` and a `.card-deck`. We use table styles for the sizing and the gutters on `.card-deck`. The `.card-deck-wrapper` is used to negative margin out the `border-spacing` on the `.card-deck`.
  283. **ProTip!** If you enable [flexbox mode](/layout/flexbox), you can remove the `.card-deck-wrapper`.
  284. {% example html %}
  285. <div class="card-deck-wrapper">
  286. <div class="card-deck">
  287. <div class="card">
  288. <img class="card-img-top" data-src="holder.js/100%x200/" alt="Card image cap">
  289. <div class="card-block">
  290. <h4 class="card-title">Card title</h4>
  291. <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
  292. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  293. </div>
  294. </div>
  295. <div class="card">
  296. <img class="card-img-top" data-src="holder.js/100%x200/" alt="Card image cap">
  297. <div class="card-block">
  298. <h4 class="card-title">Card title</h4>
  299. <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
  300. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  301. </div>
  302. </div>
  303. <div class="card">
  304. <img class="card-img-top" data-src="holder.js/100%x200/" alt="Card image cap">
  305. <div class="card-block">
  306. <h4 class="card-title">Card title</h4>
  307. <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
  308. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  309. </div>
  310. </div>
  311. </div>
  312. </div>
  313. {% endexample %}
  314. ## Columns
  315. Cards can be organized into [Masonry](http://masonry.desandro.com)-like columns with just CSS by wrapping them in `.card-columns`. **Heads up!** This is **not available in IE9 and below** as they have no support for the `column` CSS properties.
  316. {% example html %}
  317. <div class="card-columns">
  318. <div class="card">
  319. <img class="card-img-top" data-src="holder.js/100%x160/" alt="Card image cap">
  320. <div class="card-block">
  321. <h4 class="card-title">Card title that wraps to a new line</h4>
  322. <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
  323. </div>
  324. </div>
  325. <div class="card card-block">
  326. <blockquote class="card-blockquote">
  327. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  328. <footer>
  329. <small class="text-muted">
  330. Someone famous in <cite title="Source Title">Source Title</cite>
  331. </small>
  332. </footer>
  333. </blockquote>
  334. </div>
  335. <div class="card">
  336. <img class="card-img-top" data-src="holder.js/100%x160/" alt="Card image cap">
  337. <div class="card-block">
  338. <h4 class="card-title">Card title</h4>
  339. <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
  340. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  341. </div>
  342. </div>
  343. <div class="card card-block card-inverse card-primary text-center">
  344. <blockquote class="card-blockquote">
  345. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.</p>
  346. <footer>
  347. <small>
  348. Someone famous in <cite title="Source Title">Source Title</cite>
  349. </small>
  350. </footer>
  351. </blockquote>
  352. </div>
  353. <div class="card card-block text-center">
  354. <h4 class="card-title">Card title</h4>
  355. <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
  356. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  357. </div>
  358. <div class="card">
  359. <img class="card-img" data-src="holder.js/100%x260/" alt="Card image">
  360. </div>
  361. <div class="card card-block text-right">
  362. <blockquote class="card-blockquote">
  363. <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
  364. <footer>
  365. <small class="text-muted">
  366. Someone famous in <cite title="Source Title">Source Title</cite>
  367. </small>
  368. </footer>
  369. </blockquote>
  370. </div>
  371. <div class="card card-block">
  372. <h4 class="card-title">Card title</h4>
  373. <p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
  374. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  375. </div>
  376. </div>
  377. {% endexample %}