简体   繁体   English

内联块与其容器之间的附加间隙

[英]Additional gap between inline-block and its container

My code is 我的代码是

HTML: HTML:

<div id = "container">
  <div id = "content">
      Text
  </div>
</div>

CSS: CSS:

div {
  border: 1px solid;
}

#container {
   display: block;
   width: 100%;
   height: 60px;
   margin: 0;
   padding: 0;
   font-size: 24px;
}

#content {
   display: inline-block;
   vertical-align: middle;
}

Live demo: jsFiddle 现场演示: jsFiddle

There is the same issue with line-height: 60px : jsFiddle and also with centering div: jsFiddle line-height: 60px有相同的问题line-height: 60pxjsFiddle和居中div: jsFiddle

Set font-size: 0; 设置font-size: 0; for parent container and font-size: your_size; 对于父容器和font-size: your_size; for children. 为孩子。

Modified example: http://jsfiddle.net/Ry2DY/2/ 修改的示例: http : //jsfiddle.net/Ry2DY/2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM