【问题标题】:React - Center and resize font awsome iconReact - 中心和调整字体真棒图标
【发布时间】:2020-05-01 15:43:05
【问题描述】:

所以,我在 react 中制作了一个小部件组件,我需要添加一个需要居中的图标。我有这个代码:

<div  className={classes.textCenter}>
    <i className={"fas fa-lungs fa-2x"} />
</div>

但我明白了:

看到封闭元素(i 标签)居中,但图标更大。

我还有下面的jss代码:

"& .fab,& .fas,& .far,& .fal,& .material-icons": {
    position: "relative",
    display: "inline-block",
    top: "0",
    verticalAlign: "middle",
    textAlign: "center"
  },

但这似乎没有任何区别。

提前致谢。

【问题讨论】:

  • 这样行吗?
  • 它做到了!我标记了答案。

标签: css reactjs font-awesome-5


【解决方案1】:

请给家长div试试这个-:

.textCenter{
    display: flex;
    justify-content: center;
    align-items: center;
}

另外请删除任何现有图标classes

【讨论】:

    猜你喜欢
    • 2016-03-21
    • 2017-01-03
    • 2021-02-05
    • 1970-01-01
    • 2014-01-16
    • 2017-07-04
    • 1970-01-01
    • 2019-09-04
    • 2021-12-13
    相关资源
    最近更新 更多