【问题标题】:React Styled Components - Gradient [duplicate]React Styled Components - Gradient [重复]
【发布时间】:2018-04-14 02:04:24
【问题描述】:

如何将 css 渐变添加到样式化组件?

background: radial-gradient(50% 50%, circle cover, red 0, blue 100%);

【问题讨论】:

  • 你考虑过用谷歌吗?
  • @ndugger 但谷歌不是反应组件
  • @KevinB class Google extends React.Component { ... }

标签: javascript css reactjs styled-components


【解决方案1】:

styled-components 中的渐变与常规 CSS 中的渐变相同,但您的渐变语法似乎无效——例如多年前的 cover 关键字 was only in early browser implementations。试试这个:

background: radial-gradient(circle at center, red 0, blue 100%);

阅读 MDN 上的Using radial gradients 了解更多详情。

此外,DevTools(右键单击 > 检查元素)会在您的样式出现问题时告诉您:

【讨论】:

    猜你喜欢
    • 2017-06-17
    • 2021-08-26
    • 2018-03-06
    • 2020-01-08
    • 2021-01-09
    • 2019-07-09
    • 2019-02-18
    • 2020-11-03
    • 2020-12-05
    相关资源
    最近更新 更多