search

Home  >  Q&A  >  body text

css3 - 自己做的CSS网格系统里面为什么两个div不能同行?

两个width都是50%的p,设置了向左浮动,为什么它会出现换行?如果设置49%就不会了,这是为什么?

天蓬老师天蓬老师2782 days ago765

reply all(8)I'll reply

  • 巴扎黑

    巴扎黑2017-04-17 11:15:46

    box-sizing:border-box

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 11:15:46

    Try changing the border, inner margin, outer margin, etc. of the two p's to 0

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:15:46

    Problems with the calculation method of p width
    box-sizing can specify the width value to be calculated using content, margins, and borders as boundaries
    Calculating the width as a percentage may cause the total actual width to exceed the total width of the parent container. For left-floating p, it is a line break. For example, left-floating has no effect

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 11:15:46

    Is it IE7? If not, are padding and border-width set? If not, is there a box-sizing: border-box with a margin value set? show us the code.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 11:15:46

    Pay attention to the box model and consider border padding margin

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:15:46

    It is generally better to post the code for easier analysis.
    If none of the answers above work, you can take a look at this http://www.html-js.com/article/Do-not-obey-the-inlineblock-browser-on-...

    reply
    0
  • 迷茫

    迷茫2017-04-17 11:15:46

    Look at the box model. The "CSS Design Guide" makes it very clear.

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 11:15:46

    If the poster uses inline-block, then the browser actually treats the poster's two p's as inline elements, and inline elements have spaces on both sides by default. The poster tries to set font- on its parent element. size:0px; so that the space size on both sides does not take up space. Then follow a -webkit-text-size-adjust:none to solve the problem that the minimum text of the chrome system is 12px

    reply
    0
  • Cancelreply