float:left; vs display:inline; vs display:inline-block; vs display:table-cell;

后端 未结 6 1332
野趣味
野趣味 2020-11-22 07:40

My Question(s)

  1. Are any of these methods preferred by a professional web designer?

  2. Are any of these methods prefereed by a web browser when

6条回答
  •  渐次进展
    2020-11-22 08:37

    I prefer inline-block, although float is also useful. Table-cell isn't rendered correctly by old IEs (neither does inline-block, but there's the zoom: 1; *display: inline hack that I use frequently). If you have children that have a smaller height than their parent, floats will bring them to the top, whereas inline-block will screw up sometimes.

    Most of the time, the browser will interpret everything correctly, unless, of course, it's IE. You always have to check to make sure that IE doesn't suck-- for example, the table-cell concept.

    In all reality, yes, it boils down to personal preference.

    One technique you could use to get rid of white space would be to set a font-size of 0 to the parent, then give the font-size back to the children, although that's a hassle, and gross.

提交回复
热议问题