CSS Flashcards

1
Q

What is the box model?

A
  • Content
  • padding
  • border
  • margin
div {
height: 100px;
width:100px;
padding: 10px;
border. 20px;
margin: 30px;
background-color: blue;
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the property box-sizing: border-box?

A

-Border becomes part of content and the overall box will shink containing the border into the content

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

What is specificity?

A

-HTML elements can have multiple classes, they can have ids or be reference by their element type
-Now via css you can assign different values to the same element through multiple ways
-To decide what to apply specificity is used
First rule is CSS is cascading and will the last assignedment in the code
Second rule is what is more specific will override

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

How to align a block element inside another element?

A
  • Tables, Flex-box, Css gid, vanilla css
  • position: absolute
    top: 50%
    left: 50%
    transform: translate(-50%, -50%);
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the difference between static, relative, absolute and fixed position?

A
  • By default everything is static
  • By making an element relative you can move it with top: or bottom: without moving other static elements
  • By making an element absolute it goes on another alignment layer bound by its parent element. So it will stack over other elements and the other elements are not shifted by it.
  • By making an element fixxed it is like absolute but is bound to the page not the parent element.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a shadow dom?

A
  • CSS is global
  • Scoped subtree within the element

var shadowRoot = shadowHost.createShadowRoot();

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

How to build a triangle in css?

A
  • Canvas or pure css can be used
  • div mit border-top, bottom, right same amount
  • border-top and border-bottom transparent
  • border-right stays in color now it is a triangle
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are pseudo-elements?

A
  • pseudo elements are used to allow extra markup to an element without disturbing the environment
  • Pseudo elements are accessed with :: after the elementname in css like p::after {content: “Injected text”}
  • You could inject a tooltip in an element just by css without changing the html for it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are data attributed in HTML?

A

-To store data you can use data attributes
-div class=”profile” data-name”Sascha”>Profile /div>
-In css you can access this data with pseudo selectors
.profile.hover::before {
display: inline-block;
content: attr(data-name);

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

What is a pixel unit in css?

A

-An absolute unit that is always the same size whereever it is defined

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

What is a percentage unit in css?

A

-A percentage that is based of its parent element size

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

What is a vw and vh unit in css?

A

-vw is each 1% of the entire screen width
-vh is each 1% of the entire screen heigth
.It is not restricted by parent elements and will stick to the screen size, so it can break out of wrappers

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

What is a rem and em unit in css?

A
  • rem and rem are relative of a defined font size
  • rem stands for root size or the letter m
  • em stands for parents size of the letter m
  • You normally use rem because you can rely on a universal size and doesn’t need to consider parent elements
  • ems are useful in cases like where you want to scale for example divs with their font
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the differrence between flexbox and css grid?

A

-Flexbox allows to align items flexibly within a container but only for one dimension (stacking or aligning)
| | |
-Css grid cares also about 2 dimensions (x- and y axis)
- | -
| | |
- —-

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