Why does this div shift down when content is added?

前端 未结 3 1154
时光说笑
时光说笑 2021-01-12 07:34

I have a 5x5 grid and when i add content to the div, it is shifted down. Can anyone explain why this is happening?

3条回答
  •  独厮守ぢ
    2021-01-12 08:11

    If you set:

    .r5, .r4, .r3, .r2, .r1 {
      margin-left: 40px;
      > div {
        display: inline-block;
        vertical-align: top; <-- this
        width: 50px;
        height: 50px;
        border: 1px solid black;
        line-height: 50px;
        text-align: center;
      }
    }
    

    It aligns properly.

提交回复
热议问题