CSS Flashcards

1
Q

@media screen {}

@media print {}

A

allow you to provide different css rules for when content is on a screen or when content is printed

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

Block level element

A

A block-level element starts on a new line and stretches out to the left and right as far as it can.

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

inline element

A

An inline element can wrap some text inside a paragraph without disrupting the flow of that paragraph. The a element is the most common inline element that has extra functionality, since you use them for links.

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

display property

A

sets whether an element is treated as a block or inline box and the layout used for its children, such as flow layout, grid or flex.

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

main {

max-width: 600px;
margin: 0 auto;
}

A

Centers the element with id=”main” and allows it to resize if under 600px wide

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

box-sizing: “border-box”

A

When you set “box-sizing” to the value of “border-box” on an element, the padding and border of that element no longer increase its width.

Many authors just set “border-box” on all elements on all their pages.

  • { box-sizing: border-box; }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

position: relative property

A

Causes the element to be adjusted from other elements as specified

.relative-and-obvious {
position: relative;
top: -20px;
left: 20px;
}

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

position: fixed property

A

A “fixed” element is positioned relative to the viewport, which means it always stays in the same place even if the page is scrolled. As with relative, the “top”, “right”, “bottom”, and “left” properties are used.

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

position: absolute property

A

The value “absolute” behaves like “fixed” except relative to the nearest positioned ancestor instead of relative to the viewport. If an absolutely-positioned element has no positioned ancestors, it uses the document body, and still moves along with page scrolling.

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

inline-block display property

A

You can use “inline-block” for total page layout.

Elements with “inline-block” are affected by the “vertical-align” property, which you probably want set to top.
You need to set the width of each column
There will be a gap between the columns if there is any whitespace between them in the HTML

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

CSS Transitions

A

CSS transitions let you decide which properties to animate (by listing them explicitly), when the animation will start (by setting a delay), how long the transition will last (by setting a duration), and how the transition will run (by defining a timing function, e.g. linearly or quick at the beginning, slow at the end).

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

delay {

font-size: 14px;
transition-property: font-size;
transition-duration: 4s;
transition-delay: 2s;
}

font-size: 36px;
}

A

This example performs a four-second font size transition with a two-second delay between the time the user mouses over the element and the beginning of the animation effect

When the mouse hovers over it, after a delay of two seconds, a four-second transition begins which changes the font size of the text from its normal size to 36px.

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

justify-content property

A

aligns items horizontally and accepts the following values:

flex-start: Items align to the left side of the container.
flex-end: Items align to the right side of the container.
center: Items align at the center of the container.
space-between: Items display with equal spacing between them.
space-around: Items display with equal spacing around them.

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

align-items property

A

aligns items vertically and accepts the following values:

flex-start: Items align to the top of the container.
flex-end: Items align to the bottom of the container.
center: Items align at the vertical center of the container.
baseline: Items display at the baseline of the container.
stretch: Items are stretched to fit the container.

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

flex-direction property

A

defines the direction items are placed in the container, and accepts the following values:

row: Items are placed the same as the text direction.
row-reverse: Items are placed opposite to the text direction.
column: Items are placed top to bottom.
column-reverse: Items are placed bottom to top.

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

order property

A

repositions elements in the flexbox

17
Q

flex-wrap property

A

accepts the following values:

nowrap: Every item is fit to a single line.
wrap: Items wrap around to additional lines.
wrap-reverse: Items wrap around to additional lines in reverse.

18
Q

align-content property

A

set how multiple lines are spaced apart from each other. This property takes the following values:

flex-start: Lines are packed at the top of the container.
flex-end: Lines are packed at the bottom of the container.
center: Lines are packed at the vertical center of the container.
space-between: Lines display with equal spacing between them.
space-around: Lines display with equal spacing around them.
stretch: Lines are stretched to fit the container.
This can be confusing, but align-content determines the spacing between lines, while align-items determines how the items as a whole are aligned within the container.

19
Q

grid-column-start: 3

A

moves an element to the 3rd column in the grid

20
Q

grid-column-start: 3
grid-column-end: 5

A

the element will span the 3rd and 4th columns.

NOT the 5th

21
Q

grid-column-start: 3
grid-column-end: span 2

A

the element will span the 3rd and 4th columns.

22
Q

grid-area

A

shorthand to accept four values separated by slashes: grid-row-start, grid-column-start, grid-row-end, followed by grid-column-end.

grid-area: 1 / 2 / 3 / 4;

23
Q

Box Model

A

A concept that every HTML element has a box around around it, including padding, border and margin.

We can change the size of the content with the CSS width and height properties. We can add or remove padding with the padding property, set the border with the border property, and add or remove the margin with the margin property.

24
Q

block element characteristics

A

-The box fills available container space, and in most cases it fills up 100% of the available space, becoming as wide as its container.
-Each new box appears on a new line/row.
-The CSS properties width and height are respected.
-The padding, margin and border of the box will push other elements farther away from the box.

25
Q

inline element characteristics

A

-Each box appears next to each other in a single line until it fills up the available space.
-The CSS properties width and height don’t apply.
-The padding, margin and border of a box are applied, but they don’t push other inline boxes away from the box.

26
Q

inline-block characteristics

A

-Elements still get laid out left to right
-The layout takes into account the specified width and height properties

27
Q

border property

A

shorthand for border-width, border-style, border-color

border: 3px solid black;

28
Q

padding v. margin

A

padding is within the border, and attached to the content

margin is outside of the border, basically pushing other elements away

29
Q

position property

A

The CSS property position allows us to set the position of elements on a page

The position property accepts any of the following five values:

Static
Relative
Absolute
Fixed
Sticky

All properties except for static are used in conjunction with the properties top, right, bottom and left to ultimately determine an element’s position on the page.

30
Q

position: static;

A

Static is the default position value of page elements. A static element is not considered to be positioned on the page, since it will appear normally according to the page flow. The properties top, right, bottom, left and z-index do not affect static elements.

31
Q

position: relative

A

A relatively positioned element remains in its original position in the page flow (like a static element) and can be offset from that position using the top, right, bottom and left properties. The element is positioned relative to its initial place in the page flow. Relative positioning creates a stacking context – overlapping elements whose order can be set by the z-index property.

32
Q

position: absolute

A

An absolutely positioned element is removed from the page flow, and other elements around it act like it’s not there. The element is positioned in relation to its closest positioned ancestor, or, if one cannot be found, to the <html> document. It can be offset from that position using the top, right, bottom and left properties. Absolute positioning creates a stacking context – overlapping elements whose order can be set by the z-index property.

33
Q

position: fixed

A

A fixed element will remain in the same spot on the page, regardless of the size of the window or whether a user scrolls.

A fixed element is removed from the page flow, like an absolutely positioned element. However, unlike an absolutely positioned element, a fixed element’s position is relative to the <html> document itself and not to an ancestor element. It is positioned using the top, right, bottom and left properties. Fixed positioning creates a stacking context – overlapping elements whose order can be set by the z-index property.

34
Q

position: sticky

A

A sticky element remains in its original position in the page flow, and it is positioned relative to its closest block-level ancestor and any scrolling ancestors (created when overflow is hidden, scroll, auto, or overlay). It behaves like a relatively positioned element until the point at which you would normally scroll past it in the viewport. At that scrolling point, the element “sticks” to the page wherever it has been positioned by the top, left, bottom and right properties. Sticky positioning creates a stacking context – overlapping elements whose order can be set by the z-index property.

You must set at least one threshold value using top, right, bottom or left in order for sticky positioning to work. A sticky element will start off as relatively positioned until you scroll past its original position – at which point it will be fixed to the position you specified.

35
Q

transition-property

A

Specifies the name or names of the CSS properties to which transitions should be applied. Only properties listed here are animated during transitions; changes to all other properties occur instantaneously as usual.

36
Q

transition-duration

A

Specifies the duration over which transitions should occur. You can specify a single duration that applies to all properties during the transition, or multiple values to allow each property to transition over a different period of time.

37
Q

transition-delay

A

Defines how long to wait between the time a property is changed and the transition actually begins.

38
Q

animations

A

Animations are more detailed than transitions, and can be set to happen on their own. They’re complicated. So just look at the documentation when it’s time https://developer.mozilla.org/en-US/docs/Web/CSS/animation

39
Q
A