search

Home  >  Q&A  >  body text

html - 哪些情况下float会失效?

比较p没有设宽度或高度的时候,float是否会失效。
还有哪些情况会失效的?

PHPzPHPz2830 days ago1218

reply all(6)I'll reply

  • 阿神

    阿神2017-04-17 11:14:56

    Hello! When p has no width or height, and there are no width-height elements or text content in it, the p will not be displayed, but float will still take effect.

    Failure situation: Two ps at the same level, the first one is set with float:left, and the second one is not set, the first one will be out of the document flow, which means that the second p ignores the existence of the first one. Will overlap

    reply
    0
  • PHPz

    PHPz2017-04-17 11:14:56

    What do you mean by failure?

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:14:56

    Currently we only know that float does not take effect when absolute positioning and display is none. I hope other experts can answer the questions

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:14:56

    Properties not affecting flexible boxes

    Because flexible boxes use a different layout algorithm, some
    properties do not make sense on a flex container:

    • column-* properties of the multiple column module have no effect on a flex item.

    • float and clear have no effect on a flex item. Using float causes the display property of the element to compute to block.

    • vertical-align has no effect on the alignment of flex items.

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 11:14:56

    Invalid when using absolute positioning

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 11:14:56

    Display:flex will also fail, you can use margin-left:auto to solve it

    reply
    0
  • Cancelreply