Display:inline-block And Overflow:hidden Leading To Different Vertical Alignment
Solution 1:
Yes. You need to do these:
Remove the style
overflow: hidden;
. This is not needed here. You need this only when you give awidth
ortext-overflow: ellipsis;
.Add
vertical-align: bottom;
. The vertical alignment of the text will change when the display is changed frominline
toinline-block
.
Solution 2:
It seems Chrome is in error. The CSS 2.1 spec says
The baseline of an 'inline-block' is the baseline of its last line box in the normal flow, unless it has either no in-flow line boxes or if its 'overflow' property has a computed value other than 'visible', in which case the baseline is the bottom margin edge.
Since the overflow property computes to something other than 'visible' the inline-block's baseline is the bottom margin edge, which sits on the baseline of the containing line box, and therefore must raise up the contained text to allow space for the descenders of that text.
Solution 3:
Try This
<!doctype html>
<html>
<head>
<style>
.a {
display: inline;
overflow: hidden;
color: red;
}
</style>
</head>
<body>
baseline__<div class="a">test</div>__baseline
</body>
</html>
Post a Comment for "Display:inline-block And Overflow:hidden Leading To Different Vertical Alignment"