Sollicitatievraag

Sollicitatiegesprek voor de functie Front End Engineer

-

Yelp

What situation arises when you have a parent div and all it contains is a pair of floating divs? And how can you remedy the situation.

Antwoord

Antwoorden op sollicitatievragen

3 antwoorden

1

overflow:hidden;

ramonlechuga op

1

Yes, overflow:hidden is the best way to do it. Another way is to use a technique called clearfix using psuedo-element :after

Vishal op

0

When a div contains only floating elements it thinks nothing is inside so it will have a height of 0 if none is specified. This is known as a floating div clearing problem since the floating divs are not being cleared inside the parent div. There are a couple solutions, you can add an extra empty div after the floating divs with style clear:both to clear the floating divs. Only problem is this adds extra markup. Alternatively, there are some known CSS hacks such as setting the width:100% and the overflow:auto on the parent div.

Anoniem op

Voeg antwoorden of opmerkingen toe

Meld u aan of registreer u om hier een opmerking over te maken.