- Make use of
displayandpositionproperties
-
What is the
displayproperty?-
Allows you to adjust how the elements are placed on the web page
-
Some most commonly used values:
none,inline,block,inline-block,flex(more on that later), (Bonus:grid)Value block- starts on a new line - takes up the entire width inline- stays in the same line as the other elements - does not start on a new line - only takes up as much width as necessary - widthandheightproperties have no effectinline-block- combination of both blockandinline- stays in the same line as the other elements, but you can apply widthandheightvaluesnone- element does not show up flex- displayed as a block-level flex container (more later)
-
-
What is the
positionproperty?-
Allows you to adjust where the elements are placed on the web page
-
Use in conjuction with
left/right/top/bottom/z-indexto move your elements to where you want them at -
Some commonly used values:
static,relative,absolute,fixed,stickyValue static - default value for most elements relative - relative to its normal position absolute - relative its nearest not static, parent element sticky - positioned based on scroll position - toggles between relativeandfixed- will stick to a specified location when scroll location reaches a specified threshold -
staticandrelativekeep their natural space in the flow of the document -
absoluteandfixedare removed from the flow
-