강의

멘토링

로드맵

Inflearn brand logo image

인프런 커뮤니티 질문&답변

안연수님의 프로필 이미지
안연수

작성한 질문수

웹 프론트엔드를 위한 자바스크립트 첫걸음

프로젝트 적용하기

홈페이지 이미지 추가 방법 문의드립니다!

해결된 질문

작성

·

67

0

  • 세션 7, 7. 프로젝트 적용하기

프로젝트 적용 시 홈페이지 바탕화면에 이미지를 무료 이미지 사이트인 unsplash 사이트 적용 방식 외에 개인 컴퓨터 c드라이브 문서 및 다운로드 폴더에 있는 이미지를 적용하는 방법이 있나요?

unsplash 에서 개인 컴퓨터로 다운로드 받은 이미지를 적용하는 방법에 대해서 궁금합니다!

:root {
  --xlarge: 170px;
  --large: 28px;
  --medium: 18px;
  --small: 16px;
  --xsmall: 14px;
  --xxsmall: 10px;
}

body {
  margin: 0 auto;
  width: 100%;
  font-family: "Noto Sans KR", sans-serif;
  background-image: url("C:/Users/user/Downloads/image.jpeg");
  font-optical-sizing: auto;
  font-weight: 400;
  font-style: normal;
}

.main-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  position: relative;
}

.main-container .main-wrapper {
  text-align: center;
  position: fixed;
}

.main-wrapper .date {
  font-size: var(--large);
}
.main-wrapper .time {
  font-size: var(--xlarge);
  font-weight: 400;
  margin-top: -35px;
}

.main-wrapper .search {
  display: flex;
  justify-content: center;
}

.search #search-input {
  width: 600px;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  font-size: var(--medium);
  padding: 15px 0px;
  border-radius: 30px;
  border: 0px;
  text-align: center;
  margin-top: -10px;
}

.search #search-input::placeholder {
  color: rgb(169, 169, 169);
  font-size: var(--medium);
}

.quote {
  font-size: var(--small);
  position: fixed;
  bottom: 0;
  max-width: 800px;
  padding: 0 10px;
  margin-bottom: 20px;
  font-weight: 300;
  text-align: center;
}

.bookmark-open {
  width: 240px;
  padding: 15px 30px;
  font-size: var(--xsmall);
  height: 20px;
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  color: white;
  background-color: rgba(0, 0, 0, 0.5);
}

.bookmark-close {
  width: 240px;
  padding: 15px 30px;
  font-size: var(--xsmall);
  height: 20px;
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  justify-content: flex-end;
  color: white;
}

.bookmark-close div {
  cursor: pointer;
}

.bookmark-open div {
  cursor: pointer;
}

.bookmark-bar {
  width: 240px;
  background-color: rgba(0, 0, 0, 0.5);
  position: absolute;
  top: 50px;
  right: 0px;
  min-height: calc(100vh - 70px);
  padding: 10px 30px;
  color: white;
}

.bookmark-item-add-btn {
  padding: 10px;
  font-size: var(--small);
  cursor: pointer;
  display: flex;
  justify-content: center;
  border-radius: 5px;
  background-color: rgba(255, 255, 255, 0.1);
  border: rgba(241, 241, 241, 0.2) 0.5px solid;
  margin-bottom: 35px;
  margin-top: 10px;
}

.bookmark-item-add-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.bookmark-item-input-form {
  border-radius: 5px;
  background-color: rgba(255, 255, 255, 0.1);
  border: rgba(241, 241, 241, 0.2) 0.5px solid;
  font-size: var(--small);
  padding: 12px;
  margin-top: 20px;
  margin-bottom: 20px;
}

.bookmark-item-input-form .bookmark-input {
  margin-bottom: 12px;
}

.bookmark-item-input-form .bookmark-input .label {
  margin-bottom: 3px;
  font-size: var(--xsmall);
}

.bookmark-item-input-form .bookmark-input input {
  width: 200px;
  height: 20px;
  border-radius: 5px;
  margin: 5px;
}

.bookmark-item-input-btn {
  display: flex;
  justify-content: space-between;
  font-size: var(--xsmall);
  margin-top: 5px;
}

.bookmark-item-input-btn div {
  padding: 5px 35px;
  border-radius: 5px;
  border: rgba(241, 241, 241, 0.2) 0.5px solid;
  cursor: pointer;
}

.bookmark-item-input-btn div:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.bookmark-list a {
  color: white;
  display: flex;
  text-decoration: none;
}

.bookmark-list .url-icon {
  margin-right: 8px;
}

.url-icon img {
  vertical-align: middle;
}

.bookmark-list .bookmark-item {
  border-radius: 5px;
  background-color: rgba(255, 255, 255, 0.1);
  border: rgba(241, 241, 241, 0.2) 0.5px solid;
  font-size: var(--small);
  padding: 15px;
  margin-bottom: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.bookmark-item .del-btn {
  color: lightgray;
  vertical-align: center;
  font-size: var(--xxsmall);
  cursor: pointer;
}

답변 2

0

효빈 Hyobin님의 프로필 이미지
효빈 Hyobin
지식공유자

질문 감사합니다.

vscode 내부에 img 폴더를 만들고, 해당 폴더 내부에 이미지를 복사 붙여넣기해주세요!
그리고 알맞은 경로를 입력해주시면 됩니다 :)

0

안녕하세요, 인프런 AI 인턴입니다. 안연수님.

개인 컴퓨터에 저장된 이미지를 웹 페이지의 배경 이미지로 사용하려면 몇 가지 방법을 통해 가능합니다. 보통 웹 페이지를 개발할 때는 로컬 경로가 아닌, 웹 서버의 경로를 사용하여 이미지를 참조하는 것이 좋습니다. 개인 컴퓨터의 로컬 경로(C:/Users/user/Downloads/image.jpeg)는 웹 서버에서 접근할 수 없기 때문에 웹 브라우저에서는 해당 이미지를 불러올 수 없게 됩니다.

해결책:

  1. 이미지를 프로젝트 폴더에 포함시키기:
    • 개인 컴퓨터의 파일을 프로젝트 디렉터리 내에 저장한 후 사용하시면 됩니다. 예를 들어, 현재 HTML 파일과 동일한 폴더나 하위 폴더에 이미지를 저장하고 경로를 상대 경로로 지정하십시오.
   body {
     background-image: url("./images/image.jpeg");
   }

위 코드에서 ./images/image.jpeg는 이미지가 저장된 프로젝트 폴더 내 위치를 나타냅니다.

  1. 개발 서버를 통해 탐색:
    • 만약 자신의 컴퓨터가 웹 서버에 연결되어 있거나 로컬 서버를 운영 중이라면, 브라우저를 통해 해당 서버에서 파일을 불러올 수 있습니다. 예를 들어, 로컬 개발 서버에서 http://localhost:3000/images/image.jpeg 같은 URL을 사용할 수 있습니다.

참고 자료:

  1. 로컬 서버 설정 방법: 이 게시물에서는 로컬 서버를 어떻게 설정하고 운영할 수 있는지에 대해 설명합니다.
  2. 크롬 확장 프로그램 개발: 브라우저와 로컬 파일 시스템 간의 상호 작용에 대해 배우면서, 크롬 개발자 모드를 켜고 로컬 파일을 테스트하는 방법에 대해 학습할 수 있습니다.

위 방법들을 통해 개인 파일을 웹 프로젝트에 쉽게 포함시킬 수 있으며, 프로젝트를 보다 로컬 환경에 맞춰서 개발할 수 있습니다.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다. 현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

안연수님의 프로필 이미지
안연수

작성한 질문수

질문하기