2014-12-18 2 views
2

). 안녕하세요, 이유는 내가 div35의 크기로 축소되지 않고 대신 전체 크기로 유지되는 javascript에 의해 div의 배경으로 배치되는 이미지에 background-size: cover을 사용할 때 알아 내려는 것입니다. div가 표시됩니다.배경 크기 : 표지는 배경 이미지를 전체 크기로 만듭니다 (

나는 그것이 배경 이미지로 설정되었을 때 이미지 속성을 설정하는 자바 스크립트를 사용하는 것에 대해 생각해 봤지만 해키 한 해결책 인 것 같아서 분명히 어딘가에있는 문제를 해결하지 못하는 것 같습니다.

어디서 잘못 될지에 대한 도움이나 통찰력이 있으면 대단히 감사하겠습니다! 정말 고맙습니다!

CSS :

#module-background 
    { 
     text-align: center; 
     height: 400px; 
     width: 400px; 
     margin: 0; 
     padding: 0; 
     font-size: 2em; 
     color: #fff; 
     background: #888; 
     background-size: cover; 

     background-repeat: no-repeat; 
     background-attachment: fixed; 
    } 

    #module-background a 
    { 
     color: #fff; 
    } 

    #module-background h1 
    { 
     font-size: 2em; 
     padding: 0 0.3em; 
     line-height: 1em; 
    } 

    #module-background p 
    { 
     padding: 0 1em; 
    } 

    #module-background section 
    { 
     min-height: 100%; 
     text-shadow: -1px -1px 0 #000, 
        1px -1px 0 #000, 
        -1px 1px 0 #000, 
        1px 1px 0 #000; 
    } 

HTML

<div> 
    <section id="module-background"> 
     <h1 id="city">Dummy Text</h1> 
     <p> 
      <span id="temperature"> 
      </span> 
      <span id="weather"> 
       Current temperature and weather conditions 
      </span> 
     </p> 
    </section> 
</div> 
+0

'background-size : 100 % 100 %' –

답변

2

는 CSS 스타일에서이 줄을 제거 :

background-attachment: fixed; 

그것은 트릭을 할해야합니다.

+0

"Theeeeerrrrere gooooesss mmyy hheeeerrrrooooo. 그가가는대로 조심해라." Lol. 고마워, 그 일찍부터 완전히 잊었 어. 10 분 대기 후 답변을 수락합니다. – mario

관련 문제