Why is my background color not showing if I have display: inline?

后端 未结 6 2081
臣服心动
臣服心动 2020-12-11 15:30

    
       

test

<
6条回答
  •  猫巷女王i
    2020-12-11 15:57

    The div doesn't take up space if it's inline. if you want an inline element that shows as the children's height, then use display: inline-block;.

    As for a good discussion, I'd trust QuirksMode's take better than my own. The gist is that an inline element doesn't push other elements out of the way.

提交回复
热议问题