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

标签 html css safari

我有带有 display:flex 的 ul 元素和带有 display:flex 的 li 元素内的 anchor ,但是当宽度受限时, anchor 中的文本会被截断。 测试用例: http://jsfiddle.net/ypfcjfk8/4/

HTML 和 CSS 标记 家 入门 长标签长标签长标签长标签 联系我们 支持 家 入门 长标签长标签长标签长标签 联系我们 支持

.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;
}

预期行为:它应该截断整个列表而不是单个元素。

预期输出截图: enter image description here

这在 ie 11 和 Firefox、chrome 上工作正常,但在 safari 上不行。任何帮助深表感谢。提前致谢。

最佳答案

您必须为所有浏览器使用适当的 flex 声明。以下代码块使您的 fiddle 在我的 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;

查看此页面:https://css-tricks.com/using-flexbox/

关于html - 嵌套 flex 的 iOS Safari 文本截断问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40930739/

相关文章:

jquery - 如何做侧滑子菜单?

CSS:相对位置div内的绝对位置文本

safari - AppleScript Safari,在当前窗口中打开 URL

html - 在 Safari 中预览代码? [Mac 用户]

html - style.scss 中的 Angular 样式并不总是被应用

javascript - JS 添加 Action 改变类

html - 从 HTML 转换为 Wordpress.. 不确定为什么 CSS 样式丢失/不起作用?

html - 将 html 添加到 link_to

jquery - 使用 li<a> 和 jquery 突出显示子菜单

swift - 新的 Twitter 更新验证