css - 背景渐变不透明度不适用于样式化组件
问题描述
海我正在使用样式化组件,并且我的全局样式有以下代码:
const GlobalStyle = createGlobalStyle`
html{
font-family: roboto;
background: linear-gradient(45deg,rgba(137,255,255,0.5),rgba(161,252,143, 0.25), rgba(255,167,137, 1));
height: 100vw;
overflow: hidden;
}`
export default GlobalStyle
由于某种原因,背景是正确的渐变颜色,但不透明度不适用于所述渐变色。我试过了,它在普通的 html/css 中运行良好,但由于某种原因在我的 nextjs 应用程序中没有。知道为什么它不起作用吗?
测试浏览器:firefox
解决方案
下面的代码片段可能对您有用。
这里有一个样式化组件的官方 nextjs 示例https://github.com/vercel/next.js/blob/canary/examples/with-styled-components/pages/index.js
import styled from 'styled-components'
const GlobalStyle = styled.html`
font-family: roboto;
background: linear-gradient(45deg,rgba(137,255,255,0.5),rgba(161,252,143,
0.25), rgba(255,167,137, 1));
height: 100vw;
overflow: hidden;
`
export default function StyledHtml({ children}) {
return (<GlobalStyle>
{children}
</GlobalStyle >);
}
推荐阅读
- python - 如何防止在 Python 中引发自定义异常?
- typescript - 如果我们使用猫鼬,我们应该在nestJS中使用没有typeorm的实体吗
- python - 如何加速用于迭代行以查找匹配的 ID 号并从中提取数据的循环
- python - 如何在 matplotlib 中显示 sympy 方程
- c++ - C++ 数组的地址和值的关系?
- linux - 带 gp 的 openconnect 不会在命令行中提示进行 SAML 身份验证
- apache - 从 apache htaccess 中排除目录
- tcp - 由于 TCP ZeroWindow,ActiveMQ Artemis 主题消息卡住,暂停后批量重新发送
- java - java中的超级回文
- openstack - openstack-octavia:无法创建双耳盘映像