css - 离子(反应)IonIcon - 无法对齐到中心
问题描述
我正在尝试将图标与 Ionic (React) 中的中心对齐。但图标粘在左侧,如屏幕截图所示:
多伦多证券交易所代码:
type WalletBtnProps = {
icon: { ios: string; md: string };
label: string;
};
class WalletBtn extends React.Component<WalletBtnProps> {
render() {
return (
<div className="wallet-button ion-text-center">
<IonIcon icon={this.props.icon} />
<IonLabel>{this.props.label}</IonLabel>
</div>
);
}
}
CSS:
.wallet-button {
width: 100%;
text-align: center;
height: auto;
background: rgba(190, 164, 164, 0.2);
border-radius: 10px;
padding: 15px;
}
.wallet-button * {
display: block !important;
}
.wallet-button ion-icon {
font-size: 64px;
}
有关如何解决此问题的任何建议?
解决方案
在图标类中添加这些 css :
width:100%;
display:flex;
align-items:center;
justify-content:center;
这些应该可以解决您的问题。
推荐阅读
- airflow - UTC 午夜的 Apache Airflow dag 时间表
- php - Paypal 在沙盒上运行良好,但在现场不可用
- openmaptiles - 没有 docker 的 OpenMapTiles 服务器的安装过程
- ios - 打开 Instagram 帖子 iPhone 挂钩停止工作
- javascript - 如何检查导入语句是否与 JavaScript 中的外部 npm 包一起使用
- elasticsearch - 在 ElasticSearch 中自动平衡分片
- signalr - 带有 Angular 的 Azure Signalr 服务上下文
- stata - 日期格式为 %th 时的 xline 选项?
- java - 将对象元素转换为数组int [] java spring
- c++11 - 是否有可能在编译时与运行时有一个 for 循环,甚至在 c++11 中编译时间限制条件?