我正在显示label
,input
和div
元素内联,期望它们垂直对齐,这最初是有效的.
但是,当我试图允许div
内容溢出省略号时,它们不再垂直对齐
注意:这是在Chrome 46.02490.86中观察到的
p {color:red;}
input,
label,
div {
width: 50px;
display: inline-block;
margin-left: 5px;
}
label {
text-align: right;
}
.longdesc {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
Short
Longer Description
In the second example "Long" is higher up
如何在不弄乱垂直对齐的情况下实现溢出效果?
添加vertical-align: top
到您的inline-block
元素:
p {color:red;}
input,
label,
div {
width: 50px;
display: inline-block;
margin-left: 5px;
vertical-align: top;
}
label {
text-align: right;
}
.longdesc {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
Short
Longer Description
In the second example "Long" is higher up