control layouts with multiple classes
there are three way to control layout
- container(-SIZ) class
- row row-cols(-BP)(-Col)
- col(1-6)
- col(-BP)(-COL)
- col(1-12)
Containers
These classes will give hundred percent width when screen size is lower than defined view port.
container-md
this class will give uss 100% width untill the view port size is less than 768 pixel. when view ports size becomes equal or greater than view port size of medium which is 768 pixels, than that container leave the 100 percent width.
.container .container-sm .container-md range 768 to 991 .container-lg range 992 to 1199 .container-xl range 1200 to infinity. .container-fluid
Rows
Gutter
by defualut in grid system every column inside rows receives 30 pixelx padding in between them.
Formula
row-cols(-BP)(-Col)
row-cols-3 class will try to fit 3 items in a row no matter what the screen size is.
col(-BP)(-COL)
Aligning Columns
align-TYP-DIR
Layout techniques using row classes.
- we first create container
- then in container we create a div with clsss row, we can also add another class like
class= row row-cols-3
in addition to row class. - row-cols-lg-4 will try to adjust 4 cloums when viewport is lg or greater than lg.
class= row row-cols-3 row-cols-lg-4
- we add col class to every section/element.
- we may also use
class = row justify-content-center
when some units of space is empty in row to allign cloums in row. - for vertical allignment
class = row vh-100 align-items-center justify-content-center
class = col-3 align-self-end
Layout Page with column classes.
- add class of row to div.
- then add col-3 to each item. then only 4 items will fit into one row because size of the grid is 12 units. to display only two element on one row add
class= "col-6"
- we can also play with colmns layout like in row . for example we could add class of
class = col-3 col-lg-6
- example
class = "coll-lg-3 col-med-4 col-sm-6"
Column offsets
- offset-BP-COL
- COL: 1-11
example
class="offset-sm-2"
nesting colums
order
apply order to all the elements you want to order
<div class="row">
<section class"col order-2 d-flex flex-column">
<img class="order-2" src="#">
<h1></h1>
<p></p>
</section>
</div>
Vertical Alignment
- use in rows
- allign-items-ALN
- ALN: start, center, end
- works on nested colomns
Note: if items are not aligned equally then nest the elements into another row and column. row align-items-center col row col
Horizontal Alignment
- use in rows
- need col width
- justify-content-ALN
- ALN: start, center, end, around, between
individual alignment
- Use in cols
- align-self-ALN
- ALN: start, center, end, around, between
position
- position classes
- fixed-top, fixed-bottom, sticky-top (lacks-support)
Basic Display
- mimics css
- d(-BP)-TYP
- table, table-row, table-cell, flex, inline-flex
Print Display
- d-none d-print-block
Basic Flex Container
- d(-BP)(-inline)-flex (by default flex element are block level)
- d-flex works on container only
Flex Container Classes
- container classes( classes that are added to conatiner)
- Direction Class
- flex(-BP)(-DIR)(-reverse)
- DIR: (row (default), column(to stack items))
- Order
- order(-BP)-ORD
- ORD: 1-12
- Justify
- justify-content(-BP)-ALG
- ALG: start, end, center, around, between
- Wrap
- flex(-BP)-WRP(-reverse)
- WRP: wrap, nowrap
- align-content(-BP)-ALG
- ALG:start, end, center, between, around, stretch
- item classes (flex classes for individual element in the felx container)
flex for elements
- align-self(-BP)-ALG
- ALG: start, end, center, baseline, stretch
- order(-BP)-ORD
- ORD: 1-12
Floating elements
float-(BP)-SID Note use clearfix class in container to avoid loose track of individual elements.
Margin/Padding
- pb(-BP)-(N)SIZ
- PRO: (m= margin, p= padding)
- SID: t r b l x y
- SIZ: 0 1 2 3 4 5 auto
- Note N means negative it only works with margins
Visibility
- invisible
- visible
Sizing
- SIZ(-AMT)
- siz: w, h, mw, mh, vw, vh, min-vw, min-vh
- AMT: 25 50 75 100 auto
Border
- BORDER(-SID)(-COL)(-0)
- top, right, bottom, left
- Note -0 clears the border
- BORDER(-SID)(-SHA)(-SIZ)
- top, right, bottom, left
- SHA: circle, pill
- SIZ: 0, sm, lg