Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
702 views
in Technique[技术] by (71.8m points)

html - display:inline-block and overflow:hidden leading to different vertical alignment

The following code renders differently in different browsers (IE = FF = higher than baseline, Chrome = on baseline).

  1. Whose fault is it? Where should I file a bug report?

  2. Do you know a way how to get this solved cross-browser. If I change vertical-alignment, I get it to work in some browsers, but not the others.

<!doctype html>
<html>
<head>
    <style>
        .a {
            display: inline-block;
            overflow: hidden;
            color: red;
        }
    </style>
</head>
<body>
    baseline__<div class="a">test</div>__baseline
</body>
</html>

http://jsfiddle.net/T2vQj/

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes. You need to do these:

  1. Remove the style overflow: hidden;. This is not needed here. You need this only when you give a width or text-overflow: ellipsis;.

  2. Add vertical-align: bottom;. The vertical alignment of the text will change when the display is changed from inline to inline-block.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...