html - 带有文本溢出的 CSS Flexbox 边框半径 : Ellipsis

标签 html css flexbox ellipsis

我想在我的列表项上应用带有 flexbox 和省略号的边框半径,并且还想要一个 min-width,如下例所示。

<ul>
<li style="flex: 1 1;"><span>A</span></li>
<li style="flex: 2 2;"><span>this is a pretty long text that will overflow the parent container</span></li>
<li style="flex: 1 1;"><span>C</span></li>

ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

li {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    color: white;
}

span {
    background-color: blue;
    padding: 0em 1em;
    border-radius: 1em;
}

这是例子 http://jsfiddle.net/mnk/kah0bn6o/1/

目标是在应用了省略号的元素上应用边框半径

最佳答案

让它工作的一种方法是删除 <span>标签。将所有内容放入 <li>秒。

试试这个:

HTML(删除了 span 标签)

<ul>
    <li style="flex: 1 1;">A</li>
    <li style="flex: 2 2;">this is a pretty long text that will overflow the parent
                          container</li>
    <li style="flex: 1 1;">C</li>
</ul>

CSS

ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
}

li {     
    padding: 0em 1em;
    background-color: blue;
    border-radius: 2em;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    color: white;
}

演示:http://jsfiddle.net/kah0bn6o/5/

或者,您可以保留 span s 并简单地应用 border-radius规则spanli元素。

演示:http://jsfiddle.net/kah0bn6o/7/

关于html - 带有文本溢出的 CSS Flexbox 边框半径 : Ellipsis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33527292/

相关文章:

python - 如何使用 Python 在 Selenium Webdriver 中选择一个具有通用类名的元素?

css - 将图像拟合到 flex-direction : column - explanation and fixes?

html - 如何修复 Safari 中的 flex 50% 布局问题?

javascript - 如何在新页面加载后提交CFform并更改其action属性?

javascript - 增加可点击区域的输入范围

javascript - 获取简单 GET 请求的 NS_BINDING_ABORTED 错误

css - 在你的 css 选择器中包含 ng-binding 是一个不好的做法吗?

css - 带有::before 和::after 元素的中心 float

html - 在头像右侧添加图标 - Ionic

html - Div 不扩展附加文本