【问题标题】:capitalize the first letter in a word for a normal state将单词中的第一个字母大写表示正常状态
【发布时间】:2019-04-13 03:00:54
【问题描述】:
  • 我正在尝试覆盖材质 UI css。
  • 我尝试将这两个词都大写,但它仅在选中和悬停时发生变化,
  • 正常状态下也可以改吗
  • 我已调试但无法解决问题。
  • 你能告诉我如何解决它吗?
  • 在下面提供我的代码 sn-p 和下面的沙箱。

https://codesandbox.io/s/2pomwq2z20

const styles = theme => ({
  root: {
    flexGrow: 1,
    width: "100%",
    backgroundColor: theme.palette.background.paper
  },
  tabsIndicator: {
    backgroundColor: "red",
    textTransform: "capitalize"
  },
  tabRoot: {
    "&:hover": {
      color: "red",
      opacity: 1,
      textTransform: "capitalize"
    },
    "&$tabSelected": {
      color: "red",
      fontWeight: theme.typography.fontWeightMedium,
      textTransform: "capitalize"
    },
    "&:focus": {
      color: "red",
      textTransform: "capitalize"
    }
  },
  tabSelected: {}
});

【问题讨论】:

  • 你试过tabRoot: { textTransform: "capitalize", ... }吗?
  • @tholle 感谢您的回复...我已更新但仍然无法正常工作:(在此处提供更新的代码codesandbox.io/s/2pomwq2z20

标签: javascript html css reactjs material-ui


【解决方案1】:

您需要在 tabRoot 中添加textTransform: "initial"。查看https://codesandbox.io/s/p5z9m029v0

【讨论】:

  • 嘿第一个字母,我应该在 Caps 中显示搜索和收藏夹 tex
  • 嘿,它成功了...你能告诉我你为什么在 tabRoot 中添加,以便将来我自己修复它
  • 这是因为tab中的文字默认看tabRoot的CSS属性。因此,当我们转换 tabRoot 中的文本时,该 css 属性被拾取。
  • 嘿,非常感谢,您能帮我解决这个问题吗...不知道如何继续stackoverflow.com/questions/53215128/…
  • 你能帮我解决这个问题吗stackoverflow.com/questions/53265169/…
猜你喜欢
  • 1970-01-01
  • 2017-06-20
  • 2020-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-20
  • 1970-01-01
相关资源
最近更新 更多