inflearn logo
강의

Khóa học

Chia sẻ kiến thức

Những bước đầu tiên với JavaScript dành cho Web Frontend

Áp dụng vào dự án

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

Đã giải quyết

115

yeon2020

8 câu hỏi đã được viết

0

프로젝트 적용 시 홈페이지 바탕화면에 이미지를 무료 이미지 사이트인 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;
}

javascript dom

Câu trả lời 2

0

hyobin

질문 감사합니다.

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

0

communityai8509

안녕하세요, 인프런 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. 크롬 확장 프로그램 개발: 브라우저와 로컬 파일 시스템 간의 상호 작용에 대해 배우면서, 크롬 개발자 모드를 켜고 로컬 파일을 테스트하는 방법에 대해 학습할 수 있습니다.

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

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

브라우져 호환성 문의

0

67

2

4-23 Promise객체 12:05 코드 질문

0

60

2

<div class="bookmark-item-add-btn"> 질문

0

58

2

랜덤이미지

0

60

2

"6. 1. (최신 버전) 자바스크립트 코딩 환경 설정"의 화면이 정상적으로 출력되지 않습니다

1

72

2

북마크바 디폴트가 "북마크 열기"로 뜹니다.

1

130

1

북마크 추가 버튼 활성화 오류 문의드립니다!

0

113

1

북마크바 배치 문의드립니다!

0

114

2

명언 설정하는데 위치설정 오류가 있어요!

0

143

2

4:45 부터 무한로딩되어 재생이 안됩니다ㅠ

1

105

1

BigInt Type 에 대하여

0

87

1

계속 헷갈리네요. 이게 맞나요?

1

149

2

섹션 7 - 7 프로젝트 적용하기

1

121

2

섹션7 - 7 프로젝트 적용하기

0

88

1

섹션7-4 api사용해서 명언 설정하기

0

135

2

6분 53초 질문입니당

1

119

2

왜 전부다 div태그로 만드는지 궁금합니다.

1

232

2

[수업질문] bookmark.js에서

0

130

2

최종 프로젝트 적용

0

181

2

append&appendChild+메소드 호출

1

138

1

코드샌드박스 업데이트

0

168

2

async pending상태의 promise객체

1

151

2

화면이 다릅니다.

1

178

1

extensions 질문

1

1296

1