Display inline block text inside issue

后端 未结 3 806
野的像风
野的像风 2021-01-16 21:05

I have been trying out display inline-block, everything worked out great if I didn\'t add anything into the divs but when I do the div collapsed and I don\'t know exactly wh

3条回答
  •  伪装坚强ぢ
    2021-01-16 21:31

    display:inline-block creates a small gap, so add font-size:0 to parent. plus add vertical-align:top since by default inline-block is baseline

    with all of this you have fixed your issue.

    here is the snippet:

    .caja {
      background-color: gray;
      width: 100px;
      height: 100px;
      border: 1px solid black;
      margin: 5px;
    }
    .caja-grande {
      background-color: gray;
      border: 1px solid black;
      padding: 5px;
      width: 350px;
      margin: 5px;
      font-size: 0
    }
    .inline-block {
      display: inline-block;
      vertical-align: top;
      font-size: 16px;
    }
    Hola mundo

    you can find more info (and options on how to solve this in other ways) in this article Fighting the Space Between Inline Block Elements

提交回复
热议问题