html - 'clearfix' OR 'overflow: hidden' Which is better for multiple listing? -


as know there multiple ways clear div. preferred clearfix (bootstap) method.

but when there need clear list elements/divs (multiple) following code

<ul>      <li class="clearfix"> floated elements goes here.. </li>      <li class="clearfix"> floated elements goes here.. </li>      <li class="clearfix"> floated elements goes here.. </li>      .      .      .       on </ul> 

in above case, not looks convenient add class every li. instead of can use overflow: hidden;.

still there have lots of opinion on topic.

can here method recommended on above situation , why better?.

adding classes 'li' effect on page loading?

both methods achieve similar results, in cases, 1 may more advantageous other.

the use of overflow: {auto|hidden} creates new block formatting context , has implications how margins , paddings contained within parent elmement. example, new block formatting context, margins not collapse might expect.

with clearing element (either in dom or pseudo element), margins collapse expected.

beyond distinction, hard recommend 1 method on other.

comment: adding classes li

adding additional class name li elements not slow down page load time result of work broswer parse page , apply stylesheets.

unless have complex web page thousands of css rules, don't think need concerned browser performance.

what more relevant average web developer having page marked numerous classes can make maintenance more difficult. keeping stylesheets organized skill develop experience.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -