overflow:hidden和display:inline-block在一起行内对不齐

同时拥有overflow hidden 和 display inline-block 的元素,会对行内元素垂直对齐 有影响,
导致原因是 overflow hidden 改变了默认对齐方式

解决办法:添加 vertical-align: bottom

参考文档:
http://stackoverflow.com/questions/20566710/overflowhidden-displayinline-block-moves-text-upwards

This happens because the inline-block element has height equal to its parent and overflow: hidden causes its bottom edge to be aligned on the text baseline of the parent. As a result the space that is available for descenders on the text is essentially doubled for the (JSFiddle).

You can fix this by also giving it vertical-align: bottom.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        .container {
            height: 25px;
            line-height: 25px;
            border: 1px solid gray;
            width: 200px;
            font-size: 12px;;
        }
        .zhongwen {
            display: inline-block;
            overflow: hidden;
            vertical-align: bottom
        }
    </style>
</head>
<body>
<div class="container">
    <span class="zhongwen">北京</span>
    <span>BJ</span>
</div>
</body>
</html>

转自:https://blog.csdn.net/isaisai/article/details/51219726

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,180评论 1 92
  • 关键属性:transition--------让块变化的时候有过渡,而不是瞬间改变transition-prope...
    风之旅途阅读 354评论 0 0
  • 我可以把你的照片设成瘦了屏幕吗
    吴死咯发阅读 163评论 0 0
  • PSNR是采用最多的评价图像质量好坏的方法,但是,这种方法有时候与人眼感官有出入。在[1]中提出了一种PSNR修正...
    Persistently阅读 3,452评论 0 1
  • 这周空吧学习了"能力要用将来进行时",首先要建立目标,设定在自己能力之上的指标,换句话说,要选择现有能力达不到的目...
    13c78e1e6538阅读 300评论 0 0

友情链接更多精彩内容