简体   繁体   English

带嵌套flex的iOS Safari文本截断问题

[英]iOS Safari text truncation issue with nested flex

I have ul element with display:flex and anchor inside li element with display:flex but text in anchor is getting truncated when width is restricted. 我有带display:flex的ul元素和位于带display:flex的li元素内的锚,但是当宽度受到限制时,锚中的文本会被截断。 Test case: http://jsfiddle.net/ypfcjfk8/4/ 测试案例: http//jsfiddle.net/ypfcjfk8/4/

HTML & CSS markup Home Getting Started Long LabelLong LabelLong LabelLong Label Contact us Support Home Getting Started Long LabelLong LabelLong LabelLong Label Contact us Support HTML和CSS标记主页入门Long LabelLong LabelLong LabelLong Label联系我们支持主页Startup Started Long LabelLong LabelLong LabelLong Label联系我们支持

.list-element {
    display: flex;
    flex-direction: row;
    min-height: 2.71429rem;
}
.list-item-element {
    display: block;
    flex: 1 1 auto;
    padding: 10px;
}
.list-item-content {
    display: flex;
    flex: 1 1 auto;
}
.list-item-label {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
#test {
    width: 300px;
    overflow: hidden;
    border: 1px solid red;
}

Expected behaviour: it should truncate whole list not individual item. 预期的行为:应该截断整个列表而不是单个项目。

Expected output screenshot: 预期的输出截图: 在此处输入图片说明

This works fine on ie 11 and Firefox, chrome but not on safari. 在11和Firefox,Chrome浏览器上无法正常工作。 Any help is much appreciated. 任何帮助深表感谢。 Thanks in advance. 提前致谢。

You have to use proper flex declarations for all browsers. 您必须对所有浏览器使用正确的flex声明。 Following code block made your fiddle look good in my Safari (win8). 以下代码块使您的提琴在我的Safari(win8)中看起来不错。

  display: -webkit-box;      /* OLD - iOS 6-, Safari 3.1-6 */
  display: -moz-box;         /* OLD - Firefox 19- (buggy but mostly works) */
  display: -ms-flexbox;      /* TWEENER - IE 10 */
  display: -webkit-flex;     /* NEW - Chrome */
  display: flex;

Check this page out: https://css-tricks.com/using-flexbox/ 签出此页面: https : //css-tricks.com/using-flexbox/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM