Box Model Flashcards

1
Q

Box model components

A
  • Content
  • Padding
  • Border
  • Margin
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Basic Margin collapsing rules

A
  • Two positive margins will combine to become one margin. Its size will be equal to the largest individual margin. (max(a, b))
  • Two negative margins will collapse and the smallest (furthest from zero) value will be used. ((a - b)
  • If one margin is negative, its value will be subtracted from the total. (min(a, b))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Describe outer display types

A

Outer display types — they affect how the box is laid out in relation to other boxes around it.

display: block:
- The box will break onto a new line.
- The width and height properties are respected.
- Padding, margin and border will cause other elements to be pushed away from the box.

display: inline:
- The box will not break onto a new line.
- The width and height properties will not apply.
- Paddings and margin can overlap other content.

display: inline-block:
- Use it if you do not want an item to break onto a new line, but do want it to respect width and height and avoid the overlapping.

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

How to change inner display type.

A

You can change the inner display type by setting an inner display value, for example display: flex;

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

Box sizing models

A

Standard (box-sizing: content-box): when you set dimensions such as width and height, those dimensions apply to the content box. If you then set padding and border, these values are added to the content box’s size.

alternative (box-sizing: border-box) box model, any width is the width of the visible box on the page. The content area width is that width minus the width for the padding and border.

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

How to set margin / padding, all properties you remember.

A

In general, margin / padding properties can be applied to each side:
- top
- right
- bottom
- left

Shortcut have three forms:
- prop: all-sides;
- prop: top+bottom left+right;
- prop: top right bottom left; clock-wise.

Example:
- margin: 2px 1em 0 auto;
- padding: 5% auto;
- padding-bottom: 10px

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

Set border (shortcut)

A

Shortcut: width - style - color:
border: 1px solid black;

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

Set border for top of the box only (shortcut)

A

` border-top: 5px dotted green;`

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

What are border styles (most important ones)

A
  • dotted
  • dashed
  • solid
  • double
  • groove (rowkowaty)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to set rounded corners:
- All corners the same
- All corners different

A

All:
border-radius: 5%;

top-left | top-right | bottom-right | bottom-left:
border-radius: 1px 0 3px 4px;

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

How to set box shadow, what are the arguments

A

Arguments:
- Horizontal offset: positive values move the shadow right, and negative values left.
- Vertical offset: positive - up, negative - down.
- The blur radius (optional): a higher value means the shadow is dispersed more widely.
- Spread radius (optional): a larger number increases the size of the shadow and a smaller number decreases it, making it the same size as the blur radius if it’s set to 0.
- Color (optional)

box-shadow: 5px 5px 20px 5px #000;

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

Set background of div to red

A

background-color: red

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

Set some image as div background

A

background-image: url(balloons.jpg);

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

Types of gradient functions

A
  • linear-gradient() function generates an image of two or more colors, progressively.
  • radial-gradient() creates a gradient that radiates in a circular fashion instead of specifying an angle.
  • conic-gradient() has a center point in your box and starts from the top (by default), and goes around in a 360 degree circle.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What will happen if content is larger than set width or height

A

content overwrites content outside of element (overflows)

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

Common overflow settins

A
overflow: hidden;
overflow: scroll; /* add scrollbars */
overflow: auto; /* only add scroll when more content than possible */
17
Q

Break words with - when necessary

A

hyphens: manual