Layouts Flashcards

1
Q

What is a Box Model?

A

Whenever a browser renders an element, it will place it in a box model.

The innermost element in the box model is called content area. The texts are shown in the content area.

Next, we have a padding area. This is used to provide some space outside the content area.

Next, we have a border. If the border is shown, they will show it here.

Next we have a margin area to add space between the elements.

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

What is margin collapsing?

A

Margin collapsing happens when the top and bottom margins of elements are
combined into a single margin.

The size of the margin is equal to the largest of the two
margins.

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

What is block level elements?

A

Block level element will occupy the entire available horizontal space. DIvs are block level element.

Spans are inline element. They dont respect width and height property.

Hence, we have inline-block. They dont occupy entire horizontal space but they respect width and height.

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

What is display property?

A

diplay: block | span | inline-block

There are two types of HTML elements: block-level and inline.
• Block-level elements always start on a new line and take up the entire available
horizontal space. The <p> and </p><div> elements are examples of block-level elements.
• Inline elements don’t start on a new line. They take up as much width as necessary. The
<span>, <a> and <img></img> are a few examples of inline elements.
• We can size elements by setting their width and height properties. These properties
have no effect on inline elements. To size an inline element, we need to set its display
property to inline-block</a></span></div>

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

What is box-sizing?

A

When the browser renders the element, the width and height will be applied to the content of the box element. This will be difficult to manage.

box-sizing: content-box;

*,
*::before,
*::after{
box-sizing: border-box;
}

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

What is overflow?

A

Overflow occurs when an element’s content is too large to fit. Using the overflow
property we can specify what should happen when overflow occurs.

for example, create a div with 100px and 100px;
Add Lorem text of 250 words.

Overflow: hidden | scroll;

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

What are the measuring units available in HTML?

A

There are two types of measuring units -

Absolute- px
Relative - rem, em, vh, vw,

Absolute units dont change in any device and screen size.

Relative units are relative to its container.

vh/vw - relative to the viewport
em - relative to the parent’s font-size
rem- relative to root’s font size.

html{
font-size: 62.5%;
}

default height of a block-level element is 0.

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

What are different positions available in HTML?

A

There are three types of positioning:

static - default
relative: relative to its actual positon.
abslolute: relative to parent.
fixed

Create 3 boxes -

<div>
<div>
<div>
</div>

~~~
.box--one{
background: black,
position: relative,
left: 5rem;
}
~~~

using relative we can postion using trbl;

~~~
for absolute positioing, make paraeatn relative
<div>
<div>
<div>
</div>
~~~

.boxes{
position:relative;
}

~~~
.box--one{
background: black,
position: absolute,
left: 5rem;
}
</div></div></div></div>

~~~

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

What is z-index?

A

When we set the z-index the element moves towards us. default is 0. we can have - or + number.

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

What is float?

A

we can make an elemnt float.

float: left
float: right

all other elemnts will float around this element

example, create box , make it float. add two paragraphs.. These two paragarpahs will flaot.

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

What is the problem with float?

A

Parent dont see the floating elemnts and hence pareant will collapse. TO fix, we need to clear it.

to clear,

box–one::after{
clear:both,
content: ‘ ‘,
}

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