【问题标题】:CSS on React app just suddenly stopped workingReact 应用程序上的 CSS 突然停止工作
【发布时间】:2021-10-12 21:00:39
【问题描述】:

我一直在用 React 和 Material UI 编写这个网页,我决定使用普通的 CSS 样式。它到了我关闭代码编辑器并重新打开它的地步,现在某些部分的 CSS 根本没有加载。我不知道发生了什么...

这里是 Codesandbox:https://codesandbox.io/s/github/JojoDuke/fontsnatcher-landing-page?file=/src/App.js

Main.js(一个 CSS 不工作的组件示例)

import './Main.css';
import { Typography } from '@mui/material';
import fonts from '../images/fonts.png';
import podcast from '../images/Podcast.svg'


const Main = () => {
    return (
        <div className="the-div">
            <Typography className="header1" variant="h1">Discover the<img className="img-fonts" src={fonts} alt="fonts" width="320"/> being<br/> used on the web</Typography>
            <Typography className="header2" variant="h4">Fontsnatcher is a Chrome extension for designers and developers 
            that<br/> answers the question, "What font is this website using?"</Typography>
            <button className="hiw-btn">
                See How it works
            </button>

            <div className="illustration">
                <img className="img-podcast" src={podcast} alt="podcast-svg" width="700"/>
            </div>
        </div>
    )
}

export default Main;

Main.css

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@300;400;600;700;800;900&display=swap');


.the-div{
    text-align: center;
}

.header1{
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 700;
    margin-top: 160px;
}
.img-fonts{
    position: relative;
    top: 30px;
}

.header2{
    font-family: 'Nunito Sans', sans-serif;
    color: #7E7E7E;
}

.hiw-btn{
    color: #ffffff;
    background-color: #00B2FF;
    border: none;
    padding: 10px 30px;
    font-family: 'Nunito Sans', sans-serif;
    font-weight: 600;
    font-size: 20px;
    margin-top: 50px;
    transition: 0.4s;
  }
.hiw-btn:hover{
    background-color: #67d1ff;
    cursor: pointer;
  }

  .img-podcast{
      margin: -200px auto;
  }

【问题讨论】:

标签: css reactjs material-ui


【解决方案1】:

我想如果你重启服务器

【讨论】:

  • 我该怎么做?
  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多