我刚刚开始学习React,我想知道如何创建全局布局容器和全局内容容器。这就是我试图使用CSS实现的目标。但我对如何使用React来实现这一点感到困惑。将是伟大的任何建议/链接到教程等…谢谢。
.global-container {
width: 100vw;
height: 100vh;
}
.global-content {
width: 90%;
height: 100%;
margin: 0 auto;
}发布于 2021-07-05 00:47:22
既然您已经标记了styled-components,我假设您也在使用它!
//GlobalContainer.js
import styled from 'styled-components';
const Wrapper = styled.div`
width: 100vw;
height: 100vh;
`
export default function GlobalContainer({ children }) {
return (
<Wrapper>
{children}
</Wrapper>
);
}// GlobalContent.js
import styled from 'styled-components';
const Wrapper = styled.div`
width: 90%;
height: 100%;
margin: 0 auto;
`
export default function GlobalContent({ children }) {
return (
<Wrapper>
{children}
</Wrapper>
);
}发布于 2021-07-05 00:16:56
在App.js中,为全局容器和内容放置一个div,就像在HTML中一样。请注意,您必须使用className而不是class来为jsx提供css类。
import "./Styles/index.css"
function App() {
return (
<div className="global-container">
<div className="global-content">
{// Your app goes here
}
</div>
</div>
);https://stackoverflow.com/questions/68246618
复制相似问题