Advertisement
Guest User

Untitled

a guest
Aug 28th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.31 KB | None | 0 0
  1. Every web developer should know how to properly code a responsive website. Bootstrap 3 is an ultimate framework that learns you how to think when coding responsive websites and makes their creation much easier and faster. When I was learning Bootstrap 3, I was looking for a simple list of basic Bootstrap 3 classes with description and there were none - only a few lists for Bootstrap 2, without any description, therefore pretty useless for my intentions. So I created this list of Bootstrap 3 CSS classes with so much desired description - I hope it's comprehensive. Keep in mind that it's not a documentation, it's just a quick hint to help you understand the meaning of each mentioned class.
  2.  
  3. It is also not a complete list of classes, it would take days to create it and you don't really need to use (and know) all the BS3 classes. See the sources part in the bottom of this page to find out the meaning of the classes that I don't mention here (button classes for example).
  4.  
  5. Basic Bootstrap Classes
  6. .container
  7.  
  8. sets fixed width to an element (which changes depending on a screen size to other fixed values, so it's still responsive) on all screen sizes except xs - on xs, the width is calculated automatically (this behaviour can be changed)
  9. a fixed width responsive website should be wrapped in .container (or just the content without menu, whatever - it's up to you)
  10. .container can't be nested!
  11. .container-fluid
  12.  
  13. sets 100% width, margin-left and margin-right: auto, padding-left and padding-right: 15px
  14. a full screen website should be wrapped in .container-fluid
  15. .container-fluid can't be nested!
  16. .row
  17.  
  18. creates horizontal groups of columns (which usually have width classes, see below)
  19. must be within .container to ensure correct padding and alignment
  20. only columns (block elements with width classes) may be immediate children of rows
  21. sets margin-left and margin-right: -15px
  22. .pull-right
  23.  
  24. .pull-left
  25.  
  26. sets float to either left or right
  27. .center-block
  28.  
  29. sets margin-left and margin-right to auto
  30. Bootstrap Grid Classes
  31. can be nested, the nested columns must be wrapped in .row as well
  32. all columns have float: left and position: relative styles
  33. .col-xs-1
  34.  
  35. .col-xs-2
  36.  
  37. .col-xs-3
  38.  
  39. .col-xs-4
  40.  
  41. .col-xs-5
  42.  
  43. .col-xs-6
  44.  
  45. .col-xs-7
  46.  
  47. .col-xs-8
  48.  
  49. .col-xs-9
  50.  
  51. .col-xs-10
  52.  
  53. .col-xs-11
  54.  
  55. .col-xs-12
  56.  
  57. sets width of a column (specified in %) on extra small screens (<768pxt)
  58. .col-sm-1
  59.  
  60. .col-sm-2
  61.  
  62. .col-sm-3
  63.  
  64. .col-sm-4
  65.  
  66. .col-sm-5
  67.  
  68. .col-sm-6
  69.  
  70. .col-sm-7
  71.  
  72. .col-sm-8
  73.  
  74. .col-sm-9
  75.  
  76. .col-sm-10
  77.  
  78. .col-sm-11
  79.  
  80. .col-sm-12
  81.  
  82. sets width of a column (specified in %) on small screens (≥768px)
  83. .col-md-1
  84.  
  85. .col-md-2
  86.  
  87. .col-md-3
  88.  
  89. .col-md-4
  90.  
  91. .col-md-5
  92.  
  93. .col-md-6
  94.  
  95. .col-md-7
  96.  
  97. .col-md-8
  98.  
  99. .col-md-9
  100.  
  101. .col-md-10
  102.  
  103. .col-md-11
  104.  
  105. .col-md-12
  106.  
  107. sets width of a column (specified in %) on medium size screens (≥992px)
  108. .col-lg-1
  109.  
  110. .col-lg-2
  111.  
  112. .col-lg-3
  113.  
  114. .col-lg-4
  115.  
  116. .col-lg-5
  117.  
  118. .col-lg-6
  119.  
  120. .col-lg-7
  121.  
  122. .col-lg-8
  123.  
  124. .col-lg-9
  125.  
  126. .col-lg-10
  127.  
  128. .col-lg-11
  129.  
  130. .col-lg-12
  131.  
  132. sets width of a column (specified in %) on large screens (≥1200px)
  133. .col-xs-offset-* (.col-xs-offset-1, .col-xs-offset-2, .col-xs-offset-3 ... up to -12)
  134.  
  135. .col-sm-offset-* (.col-sm-offset-1, .col-sm-offset-2, .col-sm-offset-3 ... up to -12)
  136.  
  137. .col-md-offset-* (.col-md-offset-1, .col-md-offset-2, .col-md-offset-3 ... up to -12)
  138.  
  139. .col-lg-offset-* (.col-lg-offset-1, .col-lg-offset-2, .col-lg-offset-3 ... up to -12)
  140.  
  141. sets offset (margin-left) by specified number of columns (eg. set .col-sm-offset-3 class to a column to move it by three columns on small screens)
  142. .col-xs-pull-* (.col-xs-pull-1, .col-xs-pull-2 ... up to -12)
  143.  
  144. .col-sm-pull-* (.col-sm-pull-1, .col-sm-pull-2 ... up to -12)
  145.  
  146. .col-md-pull-* (.col-md-pull-1, .col-md-pull-2 ... up to -12)
  147.  
  148. .col-lg-pull-* (.col-lg-pull-1, .col-lg-pull-2 ... up to -12)
  149.  
  150. sets left position in % as it is with columns (e.g. left: 75% with -pull-9)
  151. .col-xs-push-* (.col-xs-push-1, .col-xs-push-2 ... up to -12)
  152.  
  153. .col-sm-push-* (.col-sm-push-1, .col-sm-push-2 ... up to -12)
  154.  
  155. .col-md-push-* (.col-md-push-1, .col-md-push-2 ... up to -12)
  156.  
  157. .col-lg-push-* (.col-lg-push-1, .col-lg-push-2 ... up to -12)
  158.  
  159. sets right position in % as it is with columns (e.g. right: 25% with -push-3)
  160. Bootstrap Visibility Classes
  161. you can apply all as many of these classes on a single element as you wish and this mixing gives you even more possibilities for your layout
  162. .clearfix
  163.  
  164. obvious, clear: both
  165. often combined with classes below
  166. .visible-xs-block and .visible-xs
  167.  
  168. .visible-sm-block and .visible-sm
  169.  
  170. .visible-md-block and .visible-md
  171.  
  172. .visible-lg-block and .visible-lg
  173.  
  174. displays element (sets display: block property) only on screens with specified size and hides it (sets display: none) on screens of other sizes automatically
  175. often combined with .clearfix so that clearfix is effective only on the selected screen size
  176. .visible-xs-inline-block
  177.  
  178. .visible-sm-inline-block
  179.  
  180. .visible-md-inline-block
  181.  
  182.  
  183.  
  184. .visible-lg-inline-block
  185.  
  186. displays element (sets display: inline-block property) only on screens with specified size and hides it (sets display: none) on screens of other sizes automatically
  187. .visible-xs-inline
  188.  
  189. .visible-sm-inline
  190.  
  191. .visible-md-inline
  192.  
  193. .visible-lg-inline
  194.  
  195. displays element (sets display: block property) only on screens with specified size and hides it (sets display: none) on screens of other sizes automatically
  196. .hidden-xs
  197.  
  198. .hidden-sm
  199.  
  200. .hidden-md
  201.  
  202. .hidden-lg
  203.  
  204. hides element (sets display: none property) only on screens with specified size and hides it (sets display: none) on screens of other sizes automatically
  205. .visible-print-block
  206.  
  207. displays element (sets display: block) in print (pre)view
  208. .visible-print-inline
  209.  
  210. displays element (sets display: inline) in print (pre)view
  211. .visible-print-inline-block
  212.  
  213. displays element (sets display: inline-block) in print (pre)view
  214. .hidden-print
  215.  
  216. hides element (sets display: none) in print (pre)view
  217. Bootstrap Typography Classes
  218. default font-size of <body> a <p> elements is 14px, line-height 1.428; <p> also has margin-bottom of half of its line-height (20px with 14px font), therefore 10px by default
  219. all elements like b, big, code, em, i, mark, small, strong, sub, sup, ins, del, s, u, abbr, address and blockquote (and small and cite inside) are properly styled
  220. vast majority of these classes are most often set to either paragraph, strong or em elements
  221. .page-header
  222.  
  223. class for a wrapping div of a heading
  224. adds some margin, padding and border-bottom
  225. .h1
  226.  
  227. .h2
  228.  
  229. .h3
  230.  
  231. .h4
  232.  
  233. .h5
  234.  
  235. .h6
  236.  
  237. makes an element look like heading of a chosen level
  238. .lead
  239.  
  240. for highlighting an element
  241. sets element's font-size to 21px, font-weight: 300, line-height: 1.4 and margin-bottom: 20px
  242. .text-left
  243.  
  244. .text-center
  245.  
  246. .text-right
  247.  
  248. .text-justify
  249.  
  250. aligns texts, usually paragraphs, with text-align CSS property
  251. .text-nowrap
  252.  
  253. keeps the whole text with this class on a single line, no wrapping occurs because of white-space: nowrap CSS property of this class
  254. .text-lowercase
  255.  
  256. .text-uppercase
  257.  
  258. .text-capitalize
  259.  
  260. sets text-transform CSS property to make all characters inside the element with this class lowercase, uppercase or capitalized
  261. .text-muted
  262.  
  263. makes text grey
  264. .text-primary
  265.  
  266. makes text blue
  267. .text-success
  268.  
  269. makes text green
  270. .text-info
  271.  
  272. makes text dark blue
  273. .text-warning
  274.  
  275. makes text dark yellow
  276. .text-danger
  277.  
  278. makes text red
  279. Bootstrap Lists' Classes
  280. .list-unstyled
  281.  
  282. removes list-style and margin-left on list items
  283. doesn't apply for nested lists (if needed, the nested list has to have .list-unstyled class as well)
  284. .list-inline
  285.  
  286. places list items on a single line (with display: inline-block and padding)
  287. .dl-horizontal
  288.  
  289. class for a definition list (<dl>)
  290. sets nice styles for <dt> and <dd> within the definition list (text align, font-weight)
  291. .list-group
  292.  
  293. class for the parent element (usually <ul>, but can be <div> as well) of list items
  294. list items have to have .list-group-item class
  295. .list-group-item
  296.  
  297. class for .list-group children elements
  298. for a nicer look of the list items
  299. usually on <li>, but can be <a> as well
  300. .list-group-item-heading
  301.  
  302. for a heading within .list-group-item, often <h4> or similar low-level heading
  303. .list-group-item-text
  304.  
  305. for text within .list-group-item, often in the paragraph tag or just in a span
  306. Bootstrap Tables' Classes
  307. .table
  308.  
  309. for an ordinary table
  310. table heading has only border-bottom and <td>s have only border-top
  311. .table-striped
  312.  
  313. every odd line will be darker for a nicer look (using :nth-child selector)
  314. table heading <th> has only border-bottom and <td>s have only border-top
  315. should be combined with .table class
  316. .table-bordered
  317.  
  318. table with borders all around
  319. should be combined with .table class
  320. .table-hover
  321.  
  322. class for a table
  323. adds hover/focus effect on the table's tbody rows
  324. should be combined with .table class
  325. .table-condensed
  326.  
  327. should be combined with .table class
  328. for an ordinary table with half cell padding, so rows are not that high
  329. .table-responsive
  330.  
  331. class for a wrapper (! mostly div) of a table to keep it responsive in the way that scrollbar appears on extra small devices
  332. .active
  333.  
  334. .success
  335.  
  336. .info
  337.  
  338. .warning
  339.  
  340. .danger
  341.  
  342. classes for either <tr> or just <td>
  343. sets background color for all <td> in a table row (or just one <td>) to grey (active) / green (success) / blue (info) / yellow (warning) / red (danger)
  344. Bootstrap Forms' Classes
  345. don't forget that even form elements can be in the Bootstrap grid, so don't be afraid to use .row inside a form and then col-*-* wrappers
  346. .form-group
  347.  
  348. when creating vertical forms, it's a class for its wrapper (mostly div) of each label and its input, adds some margin-bottom
  349. .form-control
  350.  
  351. for every form element (input, textarea...), gives it 100% width
  352. to make it narrower, use a narrower wrapper (row and col-*-* divs)
  353. .form-control-static
  354.  
  355. for a paragraph that replaces a form element (input...)
  356. .form-horizontal
  357.  
  358. for horizontal forms where label is on the same line as input
  359. you have to use column classes (like col-xs-10) for each label and its input (or whateveer it is)
  360. still combined with .form-group wrapper and .form-control classes
  361. .form-inline
  362.  
  363. for a single line form (but still vertical on extra small screens)
  364. often used with the placeholder attribute to not need labels
  365. labels of inline forms should get .sr-only class to be positioned so that they can't be seen (but they won't get display: none or visibility: hidden property)
  366. .input-lg
  367.  
  368. .input-sm
  369.  
  370. makes a form element like input or select either bigger or smaller than default
  371. .input-group-lg
  372.  
  373. .input-group-sm
  374.  
  375. classes for .input-group (see further)
  376. always used together with .input-group class
  377. .input-group
  378.  
  379. class for a wrapper of .input-group-addon or .input-group-btn
  380. used instead of form-group when the classes above are used
  381. .input-group-addon
  382.  
  383. class for a span that serves as a wrapper for either .glyphicon or a radio/checkbox input
  384. adds your choice (glyphicon...) on the inner edge of an input field with grey background
  385. the span with this class can be either before or after input, depends where you want the icon to show (the left or right side of the input)
  386. must be within .input-group
  387. .input-group-btn
  388.  
  389. class for a span that serves as a wrapper for a button that looks like it was within a form input
  390. the span with this class can be either before or after input, depends where you want the button to show (left or right side of the input)
  391. contains <button> (the button can also include .dropdown-toggle class, span with .caret class and data-toggle="dropdown" attribute for even more complicated buttons)
  392. must be within .input-group
  393. .caret
  394.  
  395. class for an empty span that creates a dropdown arrow
  396. .help-block
  397.  
  398. class for a span that serves as a help text for users
  399. has to be placed right after an input of a form
  400. .has-success
  401.  
  402. .has-warning
  403.  
  404. .has-error
  405.  
  406. classes for wrapping divs with .form-group class
  407. colours the label, input and .help-block span inside to green/yellow/red
  408. the label within the wrapper with one of these classes has to have .control-label class to be coloured as well
  409. .has-feedback
  410.  
  411. class for the wrapping divs with .form-group class when you also use glyphicon for the input within the wrapper
  412. To disable input, use disabled="disabled" or readonly="readonly",
  413. To disable whole fieldset, wrap form-groups to fieldset with disabled="disabled"
  414.  
  415. Bootstrap Image Classes
  416. images should have .img-responsive or .thumbnail to be responsive and be wrapped in a column wrapper (like col-xs-3...)
  417. .img-rounded
  418.  
  419. img class that provides little border-radius
  420. .img-circle
  421.  
  422. img class that provides 50% border-radius making the img circle shaped
  423. .img-thumbnail
  424.  
  425. img class that provides a 1px solid grey border, 4px padding, white background, display: inline-block property and fast CSS3 transition
  426. .thumbnail
  427.  
  428. class for a wrapping div (or <a> in case of gallery) of an image, adds some styles (border, padding, background, transition) and set's the image max-width: 100%, height: auto; display: block; and margin-left and margin-right: auto
  429. .img-responsive
  430.  
  431. img class that makes any image responsive (scaling to the parent element) as it has max-width: 100% and height: auto
  432. may not work if placed in a floating element!
  433. .caption
  434.  
  435. class for a div inside .thumbnail element (a or div) that may include h3, p, a (also buttons) for a proper margin/padding
  436. .media
  437.  
  438. class for a div (or li, whatever) that may contain an image, a heading, some <small> text and paragraphs
  439. ensures proper image margin/padding
  440. heading inside should also have media-heading attribute and should be (together with paragraphs) wrapped in a .media-body wrapper
  441. any image within should have .pull-left or .pull-right class to float
  442. .media-list
  443.  
  444. class for a list (ul, ol) that contains .media inside
  445. ensures better margin/padding
  446. .glyphicon
  447.  
  448. base class for glyphicons (font-based icons), sets font, its styles and positioning
  449. should be used on a span
  450. .glyphicon-* (replace the star with any name of a glyphicon from this list)
  451.  
  452. sets picture via font and :before CSS3 selector with content of the font
  453. must be used together with .glyphicon class to show proper image
  454. should be used on a span
  455. Bootstrap Embed Classes
  456. .embed-responsive
  457.  
  458. general class for responsive embedding wrapper
  459. .embed-responsive-4by3
  460.  
  461. .embed-responsive-16by9
  462.  
  463. specific class for the embed wrapper with ratio already set
  464. used together with .embed-responsive class
  465. .embed-responsive-item
  466.  
  467. used on the iframe or whatever it is inside the wrapper
  468. Bootstrap Navigation Classes
  469. .nav
  470.  
  471. the basic class for every navigation structure (<ul>), removes any list-style, left padding and bottom margin
  472. also sets display: block and position relative for its <li> children
  473. must be set on every navigation
  474. .active
  475.  
  476. class for a list item (nav item, li) that makes it look active / current
  477. .nav-tabs
  478.  
  479. class for navigation structure that gives it a tab style (proper borders + float: left)
  480. .nav-pills
  481.  
  482. class for navigation structure that gives it a pills style (background on active nav item)
  483. .nav-stacked
  484.  
  485. makes vertical pills navigation
  486. used together with .nav-pills (and .nav of course)
  487. .dropdown
  488.  
  489. class for an
  490. nav item to make it dropdown
  491. needs additional classes elsewhere to work (see below)
  492. .dropdown-toggle
  493.  
  494. class for an <a> which is within <li class="dropdown"> to make a dropdown menu
  495. needs additional classes elsewhere to work (see below)
  496. .dropdown-menu
  497.  
  498. class for an <ul> which is within <a class="dropdown-toggle"> to make a dropdown menu
  499. provides proper displaying and hiding
  500. the most important dropdown menu class
  501. needs .dropdown and .dropdown-toggle classes on parent elements (see above)
  502. .nav-justified
  503.  
  504. class for an <ul>, together with .nav-tabs or .nav-pills creates a navigation with centered text and links' parent elements of the same width
  505. .disabled
  506.  
  507. class for <li> in a navigation
  508. disables the link inside VISUALLY and also adds a special mouse cursor, but the link remains active - you need to remove the href attribute of the <a> to completely disable the link
  509. Bootstrap Navbar Classes
  510. the difference between nav and navbar classes is the fact that navbar can collapse the whole nav (the nav can't do it on its own)
  511. .navbar
  512.  
  513. basic class for a navigation wrapper (usually <nav>), sets border, bottom margin, min-height and position: relative
  514. if it's not supposed to be fixed, can be placed anywhere in .container or .container-fluid
  515. .navbar-default
  516.  
  517. sets other basic styles for a navigation wrapper (background gradient and box-shadow) and also its items (including .active class on <li>s)
  518. for dark colours, see .navbar-inverse below
  519. .navbar-inverse
  520.  
  521. variation of navbar-default but with dark colours
  522. never use navbar-default and navbar-inverse on one element as it doesn't make any sense
  523. .navbar-brand
  524.  
  525. sets styles for special hyperlinks and other "simple text" in a menu (float: left, bigger font size, some padding, text-shadow...)
  526. .navbar-fixed-top
  527.  
  528. .navbar-fixed-bottom
  529.  
  530. additional class to .navbar that makes the navigation fixed at the top (or bottom) of the page as you scroll
  531. used together with .navbar and also .navbar default (just to keep the nice look)
  532. you should add some top or bottom padding to your <body> to not let the navbar overflow your content
  533. .navbar-static-top
  534.  
  535. removes top, right and left border and also border-radius of your navigation
  536. .breadcrumb
  537.  
  538. class for <ul> that serves as breadcrumbs
  539. gives breadcrumbs a cool look
  540. .pagination
  541.  
  542. class for <ul> that serves as pagination
  543. properly styles <li> within this pagination also with .disabled and .active classes (keep in mind that .disabled doesn't remove link's functionality)
  544. .pagination-lg
  545.  
  546. .pagination-sm
  547.  
  548. used on <ul> together with .pagination, makes pagination either bigger or smaller than default
  549. .pager
  550.  
  551. used on <ul>, styles "Previous" and "Next" links to look better with a grey border
  552. its list items can have .previous, .next and also disabled classes for even better styling
  553. .next
  554.  
  555. .previous
  556.  
  557. used on <li> within <ul class="pager">, adds arrows to the links
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement