CSS Flashcards

1
Q

What are the names of the individual pieces of a CSS rule?

A

one or more selectors, and a declaration block in curbraces, containing property/value pairs separated by semi-colons

  • selector
  • ruleset
  • property/value pairs
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

In CSS, how do you select elements by their class attribute?

A

with .classname selector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

In CSS, how do you select elements by their type?

A

with the element’s name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In CSS, how do you select an element by its id attribute?

A

with #idname selector

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Name three different types of values you can use to specify colors in CSS.

A
    • RGB values
    • HEX codes
    • color names
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What CSS properties make up the box model?

A
    • margin
    • padding
    • border
    • content
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which CSS property pushes boxes away from each other?

A

margin

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which CSS property add space between a box’s content and its border?

A

padding

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a pseudo-class?

A
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are CSS pseudo-classes useful for?

A
    • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Name two types of units that can be used to adjust font-size in CSS.

A
    • pixels, percentages, and ems (width of letter m)

- - rem (based on font size of root html element)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What CSS property controls the font used for the text inside an element?

A

font-family:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the four components of “the Cascade”

A

in decreasing order:

    • 1 !importance
    • 2 specificity
    • 3 source order
    • 4 inheritance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does the term “source order” mean with respect to CSS?

A

–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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How is it possible for the styles of an element to be applied to its children as well without an additional CSS rule?

A

inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List the three selector types in order of increasing specificity.

A
    • type selectors
    • class selectors
    • ID selectors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Why is using !important considered bad practice?

A

– it makes debugging more difficult because it breaks the natural cascading rules of a stylesheet

18
Q

What is the default flex-direction of a flex container?

A

row: left to right

19
Q

What is the default flex-wrap of a flex container?

A

nowrap (default): all flex items will be on one line

20
Q

Why do two div elements “vertically stack” on one another by default?

A

bc divs are block elements that take up all their horizontal space

21
Q

What is the default flex-direction of an element with display: flex?

A

row (ltr)

22
Q

q) why does img {width: 100%} work?

A
    • 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
23
Q

What is the default value for the position property of HTML elements?

A

position: static

24
Q

How does setting position: relative on an element affect document flow?

A

it does not

setting relative allows things to be moved, but doesn’t move anything itself

25
Q

How does setting position: relative on an element affect where it appears on the page?

A

it does not

setting relative allows things to be moved, but doesn’t move anything itself

26
Q

How does setting position: absolute on an element affect document flow?

A
    • 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
27
Q

How does setting position: absolute on an element affect where it appears on the page?

A

align itself to first non-static position parent

28
Q

How do you constrain an absolutely positioned element to a containing block?

A
    • 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
29
Q

What are the four box offset properties?

A
    • top
    • right
    • bottom
    • left
30
Q

utility classes !?

A

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>

31
Q

What does the transform property do?

A

– 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.

32
Q

Give four examples of CSS transform functions.

A

– translate, scale, rotate, skew, and matrix (

33
Q

explain:

button:active {
transform: translateY(0.25rem);
}

A

when the button is pressed, drop it down the Y a little. it will revert when no longer pressed

34
Q

explain:

.pokeball-row .pokeball-wrapper:first-child .pokeball:first-child {
transform: rotate(30deg);
}

A

rotate by 30deg the first .pokeball child of the first .pokeball-wrapper child in the .pokeball-row parent container

35
Q

explain:

.pokeball-row .pokeball-wrapper:last-child .pokeball:first-child {
transform: rotate(-30deg);
}

A

rotate by -30deg the first .pokeball child of the LAST .pokeball-wrapper child in the .pokeball-row parent container

36
Q

The transition property is shorthand for which four CSS properties?

A
    • transition-property
    • transition-duration
    • transition-timing-function
    • transition-delay
37
Q

Give two examples of media features that you can query in an @media rule.

A
    • color
    • orientation
    • width
    • aspect-ratio
    • device-aspect-ratio
38
Q

Which HTML meta tag is used in mobile-responsive web pages?

A

– viewport

39
Q

ALWAYS USE META VIEWPORT TAG

meta name=”viewport” content=”width=device-width, initial-scale=1”

what does that say?

A

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!! )

40
Q

What is a breakpoint in responsive Web design?

A
    • a point at which the @media fires

- - a point at which the layout will change

41
Q

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?

A

– scales to all size displays

42
Q

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?

A

– Source Order: lower on the page = winner