>  Q&A  >  본문

내 앱이 React의 index.css에 복사된 CSS를 적용하지 않습니다.

그래서 나는 YouTube에서 ReactJS에 대한 튜토리얼을 따르고 있는데 YouTube 사용자가 나에게 CSS 파일을 내 index.css로 가져오라고 말했습니다. 그러면 웹 사이트의 렌더링이 올바르게 표시되어야 합니다. 그러나 CSS를 복사하여 내 App.js를 실행했는데 Index.js에 아무 것도 나타나지 않습니다. 이 문제를 처리하는 방법을 아는 사람이 있습니까? React 버전의 스타일이 다른가요? 제가 놓친 다른 설정이 있나요?

index.css는 다음과 같습니다.

으아악

이것은 내 App.js와 Index.js입니다

으아악

마지막으로 App.js:

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400&display=swap');


* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Poppins', sans-serif;
}

.container {
  max-width: 500px;
  margin: 30px auto;
  overflow: auto;
  min-height: 300px;
  border: 1px solid steelblue;
  padding: 30px;
  border-radius: 5px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.btn {
  display: inline-block;
  background: #000;
  color: #fff;
  border: none;
  padding: 10px 20px;
  margin: 5px;
  border-radius: 5px;
  cursor: pointer;
  text-decoration: none;
  font-size: 15px;
  font-family: inherit;
}

.btn:focus {
  outline: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-block {
  display: block;
  width: 100%;
}

.task {
  background: #f4f4f4;
  margin: 5px;
  padding: 10px 20px;
  cursor: pointer;
}

.task.reminder {
  border-left: 5px solid green;
}

.task h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.add-form {
  margin-bottom: 40px;
}

.form-control {
  margin: 20px 0;
}

.form-control label {
  display: block;
}

.form-control input {
  width: 100%;
  height: 40px;
  margin: 5px;
  padding: 3px 7px;
  font-size: 17px;
}

.form-control-check {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.form-control-check label {
  flex: 1;
}

.form-control-check input {
  flex: 2;
  height: 20px;
}

footer {
  margin-top: 30px;
  text-align: center;
}

P粉895187266P粉895187266184일 전405

모든 응답(1)나는 대답할 것이다

  • P粉930534280

    P粉9305342802024-03-31 00:32:36

    index.css를 index.js 파일로 가져와야 합니다. 따라서 app.js에서 가져오기를 직접 삭제할 수 있습니다.

    가져올 경로로 "./index.css"를 사용하고 있기 때문에 index.css 파일이 index.js와 같은 폴더에 있는지 확인해야 합니다(src 폴더인 것 같습니다).

    회신하다
    0
  • 취소회신하다