CSS Flashcards
What are the names of the individual pieces of a CSS rule?
one or more selectors, and a declaration block in curbraces, containing property/value pairs separated by semi-colons
- selector
- ruleset
- property/value pairs
In CSS, how do you select elements by their class attribute?
with .classname selector
In CSS, how do you select elements by their type?
with the element’s name
In CSS, how do you select an element by its id attribute?
with #idname selector
Name three different types of values you can use to specify colors in CSS.
- RGB values
- HEX codes
- color names
What CSS properties make up the box model?
- margin
- padding
- border
- content
Which CSS property pushes boxes away from each other?
margin
Which CSS property add space between a box’s content and its border?
padding
What is a pseudo-class?
A CSS pseudo-class is a keyword added to a selector that specifies a special state of the selected element(s) (can be a user-prompted state or a passive relational state). ex: :hover, :focus, :playing, :visited, :nth-child(odd)
What are CSS pseudo-classes useful for?
- user feedback, allows changing of elements as user interacts with them
- responding to changing states of elements on the site
- selecting elements by various relationships, types, states
Name two types of units that can be used to adjust font-size in CSS.
- pixels, percentages, and ems (width of letter m)
- - rem (based on font size of root html element)
What CSS property controls the font used for the text inside an element?
font-family:
What are the four components of “the Cascade”
in decreasing order:
- 1 !importance
- 2 specificity
- 3 source order
- 4 inheritance
What does the term “source order” mean with respect to CSS?
–the order rules are written and read in CSS
Source order is, simply put, the order that your CSS rules are written in your stylesheet.
“…in a specificity tie, the last rule defined wins.”
How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?
inheritance
List the three selector types in order of increasing specificity.
- type selectors
- class selectors
- ID selectors
Why is using !important considered bad practice?
– it makes debugging more difficult because it breaks the natural cascading rules of a stylesheet
What is the default flex-direction of a flex container?
row: left to right
What is the default flex-wrap of a flex container?
nowrap (default): all flex items will be on one line
Why do two div elements “vertically stack” on one another by default?
bc divs are block elements that take up all their horizontal space
What is the default flex-direction of an element with display: flex?
row (ltr)
q) why does img {width: 100%} work?
- by default images will take up their full size.
- img {width: 100%} will constrain the image to the size of the container.
- this solves the problem of the image going beyond the container.
- requires the parent div to have a size set
What is the default value for the position property of HTML elements?
position: static
How does setting position: relative on an element affect document flow?
it does not
setting relative allows things to be moved, but doesn’t move anything itself
How does setting position: relative on an element affect where it appears on the page?
it does not
setting relative allows things to be moved, but doesn’t move anything itself
How does setting position: absolute on an element affect document flow?
- other elements will act as if it doesn’t exist
- that element no longer effects the positions of others on the page
- removes from the normal flow of doc, sits above now
How does setting position: absolute on an element affect where it appears on the page?
align itself to first non-static position parent
How do you constrain an absolutely positioned element to a containing block?
- assign position: relative on the container
- assign a non-static position value to container
- absolute/fixed will look for the first relative/non-static container to align itself to
What are the four box offset properties?
- top
- right
- bottom
- left
utility classes !?
make single-purpose utility classes in css to assign to elements in html, rather than adding properties to each element in css
<div>
.util-2 {
itOnlyDoes: one-thing;
orMaybe: two-things;
}</div>
What does the transform property do?
– allows adjustment of an element on the page
The transform CSS property lets you rotate, scale, skew, or translate an element. It modifies the coordinate space of the CSS visual formatting model.
Give four examples of CSS transform functions.
– translate, scale, rotate, skew, and matrix (
explain:
button:active {
transform: translateY(0.25rem);
}
when the button is pressed, drop it down the Y a little. it will revert when no longer pressed
explain:
.pokeball-row .pokeball-wrapper:first-child .pokeball:first-child {
transform: rotate(30deg);
}
rotate by 30deg the first .pokeball child of the first .pokeball-wrapper child in the .pokeball-row parent container
explain:
.pokeball-row .pokeball-wrapper:last-child .pokeball:first-child {
transform: rotate(-30deg);
}
rotate by -30deg the first .pokeball child of the LAST .pokeball-wrapper child in the .pokeball-row parent container
The transition property is shorthand for which four CSS properties?
- transition-property
- transition-duration
- transition-timing-function
- transition-delay
Give two examples of media features that you can query in an @media rule.
- color
- orientation
- width
- aspect-ratio
- device-aspect-ratio
Which HTML meta tag is used in mobile-responsive web pages?
– viewport
ALWAYS USE META VIEWPORT TAG
meta name=”viewport” content=”width=device-width, initial-scale=1”
what does that say?
it says:
whatever device is being used to view this page make sure you set the width of that device equal to the width of the webpage
( it’s so important that it’s included in the basic html skelly that’s gets made when you do this:
! + TAB = instant HTML skelly!! )
What is a breakpoint in responsive Web design?
- a point at which the @media fires
- - a point at which the layout will change
What is the advantage of using a percentage (e.g. 50%) width instead of a fixed (e.g. px) width for a “column” class in a responsive layout?
– scales to all size displays
If you introduce CSS rules for a smaller min-width after the styles for a larger min-width in your style sheet, the CSS rules for the smaller min-width will “win”. Why is that?
– Source Order: lower on the page = winner