[英]Styled-component and Material component (Media queries)
I have some difficulty to understand media queries with MUI and styled component.我很难理解带有 MUI 和样式组件的媒体查询。 I understand that this following syntax is from styled-component
我了解以下语法来自 styled-component
Syntax 1:语法 1:
const Video = styled.video`
width: 860px;
@media ${device.mobileSM} {
width: 90%;
}
`;
and there is this one,还有这个,
Syntax 2:语法 2:
const TitleAssociation = styled(Typography)({
fontSize: '45px',
margin: '0px',
fontWeight: '400',
});
I have two questions related to this question.我有两个与这个问题有关的问题。 First, what is the specific name for both syntax.
首先,这两种语法的具体名称是什么。 I have some difficulty to find their name on google.
我很难在谷歌上找到他们的名字。 Second, I'd like to know how to put the media query in the syntax 2 to be similar like the next syntax below.
其次,我想知道如何将媒体查询放在语法 2 中,以便类似于下面的下一个语法。
Syntax that doesn't work:无效的语法:
const TitleAssociation = styled(Typography)({
fontSize: '45px',
margin: '0px',
fontWeight: '400',
@media ${device.mobileSM} {
width: 90%;
}
});
When I'm trying to use this syntax, it says./src/pages/homepage.jsx SyntaxError: C:\Users\David\Desktop\website\app\src\pages\homepage.jsx: Support for the experimental syntax 'decorators-legacy' isn't currently enabled (58:5):当我尝试使用此语法时,它会显示。 decorators-legacy' 当前未启用 (58:5):
I searched on stack overflow for this error and it says to npm install a module, but is there a solution without doing that我在堆栈溢出上搜索了这个错误,它说 npm 安装一个模块,但是有没有不这样做的解决方案
Nvm I found it, I just need to do that Nvm 我找到了,我只需要这样做
const TitleAssociation = styled(Typography)`
margin: 0px;
font-weight: 400;
font-size: 40px;
@media ${device.mobileSM} {
font-size: 30px;
}
@media ${device.mobileXS} {
font-size: 21px;
}
`;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.