css background-image 오류

2021-03-13 (토) 03:03:16 4,484

<css>

.visual{background-image: url('/img/visual.PNG') no-repeat center; background-size: cover; height: 700px; width: 100%;}

.visual .inner{width: 1200px; margin: 0 auto}

<html>

<div class="visual">

        <div class="inner">

        </div>

    </div>

img 폴더에 이미지 들어가 있는거 확인했고, css랑 연결하는 상위링크 확인했고, 다 확인했는데 이미지가 안뜨네요  왜이런걸까요

|

답변 3개

2021-03-16 (화) 20:50:17

이거 질문한 사람입니다:) 

이게 braket에서는 정상작동하는데 visual studio code에서는 아예 안되네요,,,, 

왜그런지는 아직도 모르겠지만 일단 이렇게 해결되었습니다

Copy
.visual{
  background-image: url('/img/visual.PNG');
  position:absolute;
  top:0;
  left:0;
  width:100%;
  height:700px;
  display:flex;
  justify-content:center;
  align-items:center;
  background-attachment:fixed;
  background-size:cover;
  background-position:50%;
  opacity: .1;
  z-index:-1;
}

'/img/visual.PNG'는 최상위 디렉토리 /img에 "visual.PNG" 파일이 있어야합니다.

수정 전

background-image

수정 후

background

더 자세한 건, 아래 참고해 보세요.

https://codepen.io/sinbi/pen/MWbLEVq

https://homzzang.com/b/css?sca=background

https://homzzang.com/b/free-5017

답변을 작성하려면 로그인이 필요합니다.