css - 在 flex 对象中开始一个新行
问题描述
<Popper id={"simplePopper"} open={this.context.loading}
style={{display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: 'red',opacity:'0.5',width:'100%',height:'100%'}}>
<i className="fas fa-5x fa-circle-notch fa-spin"></i>
Loading....
<Popper>
在这种情况下,fa-spin icon
和loading...
在同一行。
所以我尝试了一些,
<i className="fas fa-5x fa-circle-notch fa-spin"></i>
<br/>
Loading....
或者
<p>
<i className="fas fa-5x fa-circle-notch fa-spin"></i>
</p>
<p>
Loading....
</p>
或者
<div>
<i className="fas fa-5x fa-circle-notch fa-spin"></i>
</div>
<div>
Loading....
</div>
任何方式都不会换行。
我怎样才能分开icon
和Loading...
??
我用这段代码解决了。
谢谢您的帮助
<div>
<div style={{flexWrap: "wrap", width:"100%"}}>
<i className="fas fa-5x fa-circle-notch fa-spin"></i>
</div>
<div>
<Typography variant="h5" component="h2">
Loading..
{this.context.progress}
</Typography>
</div>
</div>
解决方案
您可以添加到父级flex-wrap: wrap;
,第一个子级的宽度必须为 100%。
或者您可以设置flex-direction: column
是否只有 2 个子元素。
推荐阅读
- vue.js - vue 淡入淡出过渡仅在元素离开而不进入时起作用
- javascript - App.post 返回空的花括号集
- ionic-framework - 如何使用 Ionic 5-React 在 IonGrid 上启用水平滚动
- go - 加密的确定性伪随机字节
- javascript - ```type="module"``` 或导入时函数不起作用
- c++ - 实现自定义电源运算符时非常奇怪的错误
- java - 每当我按下按钮时,如何制作一个令人耳目一新的项目面板?
- flutter - 在 Flutter 中识别字符串中的日期
- rest - 远程 VM 上的 TensorFlow Serving 以服务来自客户端的 HTTP 预测请求
- linux - 如何获取数组中的最大值和最小值?