- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
进一步扩大这个最近的问题:
When using `nowrap` within a flex row, avoid pushing the last elements off the screen
我很难理解为什么只有一个 flex parent - 会破坏所引用问题中建议的完美布局。
预期行为:文本将被剪切,为远端的表情符号留出空间。没有水平滚动。
请尝试打开和关闭 flex
属性以了解行为。
此外,请注意,理解为什么 wrapping flex 会破坏布局,是我在这个问题中的主要目标。所以解决它是不够的。
有没有办法解决这个问题,而不用像 flex-direction: column
这样奇怪的解决方案?
body {
margin: 0;
}
.single-flex {
display: flex;
justify-content: space-between;
}
span {
white-space: nowrap;
overflow: hidden;
}
.icon {
flex: 0 0 auto;
}
<div style="display:flex">
<div class="single-flex">
<span>hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello </span>
<span class="icon">🛑</span>
<span class="icon">🛑🛑</span>
</div>
</div>
flex-shirnk
在这里也没有任何效果。
最佳答案
从第一个 div 中删除 style="display:flex"
。
然后在第一个 .icon
上添加一个 margin-left: auto
,这样当文本不多时,红色圆圈就在右边。
body {
margin: 0;
}
.single-flex {
display: flex;
justify-content: space-between;
}
span {
white-space: nowrap;
overflow: hidden;
}
.icon {
flex: 0 0 auto;
}
.push {
margin-left: auto;
}
<div>
<div class="single-flex">
<span>hello hello </span>
<span class="icon push">🛑</span>
<span class="icon">🛑🛑</span>
</div>
</div>
<div>
<div class="single-flex">
<span>hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello </span>
<span class="icon push">🛑</span>
<span class="icon">🛑🛑</span>
</div>
</div>
关于css - 拥有 flex-parent 会破坏单项 flex 布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49068385/
我正在创建一个项目来使用评级系统评估不同的产品,但由于我是新手,所以我有几个问题。 首先,为了实现这个目标,我创建了一个 ListView ,它允许我使用从该数据库获取的 JSON 代码显示 MySQ
在对学校的大型作业进行故障排除时,我发现了一个错误,我将单个项目列表(包含一个项目的堆栈)视为单个项目。我解决了我的问题,但是在进一步的测试中我注意到一些奇怪的事情: 48 ?- 1 is [1].
嘿,我正在修改我在 Internet 上找到的示例应用程序。 (学习2破解)我想在我的 ReclycerView 中获取单行的 ID。这是代码。 主要 private void initVie
我在一个项目中使用 ASP.NET MVC SiteMap 提供程序,它运行良好。但是,我很难弄清楚如何隐藏菜单项。我想在全局导航中隐藏的菜单项是我的“站点地图”页面。现在我知道有一个东西叫做 Vis
我是一名优秀的程序员,十分优秀!