2017-04-22 4 views
1

에서 별도의 폴더에 그래픽을 저장하는 방법은 다음과 같은 파일 및 디렉토리 구조를 가지고 :웹 페이지

site\ 
site\index.html 
site\background.jpg 
site\CSS\ 
site\CSS\main.css 
site\Graphics\ 
site\Graphics\background.jpg 

* 참고 : background.jpg 두 장소에서 디스크에 있습니다.

그래픽 폴더에서 이미지가로드되지 않고 메인 (사이트) 폴더에서만 이미지가로드됩니다.

HTML :

<body> 
<div id='main'> 
    <div id='header'> 
     <div id='logoCompany'> 
      <img class='headerGraphics' src='Graphics\logo smaller.jpg'><img class='headerGraphics' src='Graphics\Marvelous Header3 small.png'> 
     </div> 
    </div> 
    <div id='contentParent' class='floatClear'> 
     <div id='content' style = "text-align: center;"> 
      <div id='leftPane'> 
       Left Col 
      </div> 
      <div id='rightPane'> 
       Right Col 
      </div> 
     </div> 
    </div> 
    <div id='footer'> 
    Footer  
    </div> 
</div> 
</body> 

CSS :

* { 
    margin: 0px; 
} 
.floatClear { 
    clear: both; 
} 

.headerGraphics { 
    display: inline; 
} 

#header { 
    background: #023489; 
    text-align: center; 
} 

#logoCompany { 
    display: inline; 
} 
#contentParent {  
    height: 2200px; 
    width: 100%; 
    background-image: url(background.jpg); 
} 
#leftPane { 
    background: yellow; 
    float: left; 
    margin: 100px 0 0 10%; 
    opacity: .5; 
    width:40%; 
}  
#rightPane { 
    background: green; 
    float: right; 
    margin: 100px 10% 0 0; 
    opacity: .5; 
    width:40%; 
} 
#footer { 
    width:100%; 
} 

나는 시도했다 :

background-image: url(background.jpg) works. 
background-image: url(..\Graphics\background.jpg) does NOT work. 
background-image: url(Graphics\background.jpg) does NOT work. 

사람은이 작업을 얻는 방법을 알아? 내부에 아무것도 앞에 바로 "\"를 포함, 경로에서이 W3Schools의 페이지 html_filepaths

+0

파일 구조의 스크린 샷을 제공 할 수 있습니까? – Squeakasaur

답변

0

이 시도 자체입니다) 서브 디렉토리입니다.

같은 폴더에있는 파일이고 "\"를 사용하는 경우 하위 폴더를 확인하려고하는 것처럼 파일을 볼 것이므로 하위 폴더를 확인하라는 지시가 있기 때문에 "\"이 작동하지 않습니다. 하위 폴더에 있어야한다면 각 폴더 앞에 순서대로 "\"를 넣고 파일 이름 앞에 붙여 넣으십시오.

+1

굉장 !! 고맙습니다!! – Fred

0

체크 아웃 상대 파일 경로에 대한 자세한 참고로

background-image: url('../Graphics/background.jpg'); 

을 (또는 :