IE7 中内联跨度的奇怪换行
我有以下内容:
HTML:
<div class='container'>
<div class='height'></div>
<div class='valign'>
<div class='ie'>
<span>short text</span>
<span>short text</span>
<span>long text...</span>
</div>
</div>
</div>
CSS:
div.container{float:left;width:550px;display:table;}
div.container div.height{height:40px;}
div.container div.valign{display:table-cell;vertical-align:middle;white-space:normal;}
div.container div.valign div.ie{text-indent:-5px;}
div.container div.valign div.ie span{white-space:normal;}
IE7 特定:
div.container div.height{float:left;}
div.container div.valign{position: relative;top: 50%;white-space:normal;}
div.container div.valign div.ie{position: relative;top: -50%;white-space:normal;}
div.container div.valign,
div.container div.valign span{zoom: 1;white-space:normal;}
在 IE7 中,当带有“长文本...”的跨度的宽度大于该行上的可用空间时,它会中断到新行。所以我最终得到:
short text short text
long text...more long text...
而不是:
short text short text long text...
more long text...
是的,我知道,丑陋的垂直对齐黑客...你能做什么...
有人有解决方案吗?
I have the following:
HTML:
<div class='container'>
<div class='height'></div>
<div class='valign'>
<div class='ie'>
<span>short text</span>
<span>short text</span>
<span>long text...</span>
</div>
</div>
</div>
CSS:
div.container{float:left;width:550px;display:table;}
div.container div.height{height:40px;}
div.container div.valign{display:table-cell;vertical-align:middle;white-space:normal;}
div.container div.valign div.ie{text-indent:-5px;}
div.container div.valign div.ie span{white-space:normal;}
IE7 specific:
div.container div.height{float:left;}
div.container div.valign{position: relative;top: 50%;white-space:normal;}
div.container div.valign div.ie{position: relative;top: -50%;white-space:normal;}
div.container div.valign,
div.container div.valign span{zoom: 1;white-space:normal;}
In IE7, the span with "long text..." breaks onto a new line when it's width is larger than the space available on the line. So I end up with:
short text short text
long text...more long text...
rather than:
short text short text long text...
more long text...
yes, I know, ugly vertical align hack... what can you do...
anyone have a solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题是
删除这一行可以解决问题(而且作为奖励,垂直对齐仍然有效!)。从跨度中删除文本也解决了问题,但我需要访问文本,因此需要将其包含在内。
Problem was with the
Removing this line fixes the issue (and as a bonus, the vertical align still works!). Removing the text from the span also fixed the problem, but I needed access to the text, so it needed to be contained.