Section 9 - Flexbox Flashcards
When should you only use a table element?
when you’re trying to actually create a table
When should you not use the table element?
to layout the styling of your website
position: ____ takes blocks out of the normal flow of HTML and has them floating above the other content
position: absolute
How to use float correctly?
when you want to float an image to the left or right of a block of text to wrap the text around it
(do not use for layout)
In summary, how do you use Flexbox?
You drop your divs inside a container and then target that container in your CSS and set the display to “flex”
display: flex is a part of the display: inline, block, inline-block, none system. T or F?
False
display: flex is its own, completely different system with a different set of rules
Different elements by default will have ______
different elements by default will have different display values
By default, what display value does a div have?
it’s going to be a full-width block by default (across the entire page)
By default, what display value does span have?
by default it’s going to be an inline element
What happens to default display values when you enclose all of th elements you want to display inside a flexible container?
the default display values get ignored/overridden and Flexbox will lay everything out
The width of each of the elements inside the Flexbox will normally be based on the ___ ___
content size
(when overriding default display values for elements inside a container)
When using gap, how do you make the gap static and more responsive? (2)
static example - gap: ##px
responsive example - gap: #rem
What does rem mean again?
rem is a unit that is going to adapt based on the top-level size of your content
(is responsive)
What happens when you set a container to display: inline-flex?
Similar to inline-block, it allows the Flexbox to occupy as much space as it needs but it means that other things can also go on the same line
What are the 2 versions of creating a flexbox container that we learned?
display: flex
display: inline-flex
Does a flexbox container need to contain all divs?
No! It can contain whatever element you want to flex such as list items to create a horizontal nav bar
How do you get rid of bullet points in a list?
add list-style: none to a li element selector section
li {
list-style: none;
}
What are 2 ways to add numbers to a box model?
- px
- %
How do you indicate that there are multiple words when using a font-family name
use quotation marks around the name
ex: font-family: “Times New Roman”, serif
Is the table element still used in modern web design?
Yes, but only used when you’re actually trying to create a table not use it for positioning (like to show your sales, visitor counts, etc)
What method replaced the table property in terms of web page layout?
the display property
What are the 4 options for the display property?
- display: inline
- display: block
- display: inline-block
- display: none
Can you set the width/height with display: inline?
No, it defaults to the size of their content (HTML)
Can you set the width/height with display: inline-block?
Yes, and the elements can go inline with each other as well
What was the problem with using display property for layout purposes?
It’s a painful process to make it a specific style you want and it’s very inflexible (have to keep fiddling the more you add)
What was a better alternative to using table in the past?
float element (2005 - 2010)
Nowadays we only use float for what purpose?
to float an image to the left or right of a block of text to wrap the text around it
( use flexbox, grid, bootstrap, etc for page structure)
How do you add a space in between each column when using flex?
gap
ex:
gap: 10px;
What is the default HTML flow?
Things will continue stacking (either inline, or on top of each other if block) from the top to the bottom of the page.
By default, what is flex-direction set to?
row
flex-direction: row;
When it comes to flex-direction, a tip is to think about what?
the direction the next item is going to be stacked onto the page (left to right, top to bottom?)
When you have flex-direction: row, the main-axis and cross-axis are set to what direction?
main-axis: horizontal (left to right)
cross-axis: vertical (top to bottom)
When you have flex-direction: column, the main-axis and cross-axis are set to what direction?
main-axis: vertical (top to bottom)
cross-axis: horizontal (left to right)
flex-basis and a number of other properties are flexing along what?
the main-axis
What does the flex-basis property do?
Depending on the main-axis direction, it can tweak the width or the height
Can flex-basis be applied to a parent container?
No, it can only be applied to the items (child elements)
When flex-basis is applied to a container that has flex-direction: column, what is it changing?
the height (of each of the items inside the container)
When flex-basis is applied to a container that has flex-direction: row, what is it changing?
the width (of each of the items inside the container)