2017-01-07 6 views
1

내 배경 크로스 페이딩이 AT ALL에서 작동하지 않는 문제가 있습니다. 어쩌면 누군가 내가 뭘 잘못했는지 말할 수 있을까요? :) 다음은 스크립트의 :CSS 배경 크로스 페이딩 문제

HTML :

<div class="bg"> 
    <div class="backgroundchange"> 
     <div class="bgimg" id="bg1"> 
      <div class="title centerV"> 
       <div> 
        <div class="text"> 
         <h1>Malarstwo</h1> 
         <p>Beaty Domanskiej</p> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div class="bgimg" id="bg2"> 
      <div class="title centerV"> 
       <div> 
        <div class="text"> 
         <h1>Malarstwo</h1> 
         <p>Beaty Domanskiej</p> 
        </div> 
       </div> 
      </div> 
     </div> 
     <div class="bgimg" id="bg3"> 
      <div class="title centerV"> 
       <div> 
        <div class="text"> 
         <h1>Malarstwo</h1> 
         <p>Beaty Domanskiej</p> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 

CSS : 결과

.bgimg { 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    position: absolute; 
    background-repeat: no-repeat; 
    background-position: center center; 
    transform: scale(1); 
    -webkit-box-shadow: inset 4px 1px 77px 40px rgba(0,0,0,0.78); 
    -moz-box-shadow: inset 4px 1px 77px 40px rgba(0,0,0,0.78); 
    box-shadow: inset 4px 1px 77px 40px rgba(0,0,0,0.78); 
    top: 0; 
    left: 0; 
    height: 100%; 
    width: 100%; 
} 

#bg1 { 
    background-image: url("../img/gallery/slonecz.jpg"); 
} 

#bg2 { 
    background-image: url("../img/gallery/motyl.jpg"); 
} 

#bg3 { 
    background-image: url("../img/gallery/slonecz.jpg"); 
} 

@keyframes backgroundchangeFadeInOut { 
    0% { 
     opacity: 1; 
    } 

    17% { 
     opacity: 1; 
    } 

    25% { 
     opacity: 0; 
    } 

    92% { 
     opacity: 0; 
    } 

    100% { 
     opacity: 1; 
    } 
} 

@-webkit-keyframes backgroundchangeFadeInOut { 
    0% { 
     opacity: 1; 
    } 

    17% { 
     opacity: 1; 
    } 

    25% { 
     opacity: 0; 
    } 

    92% { 
     opacity: 0; 
    } 

    100% { 
     opacity: 1; 
    } 
} 

#backgroundchange div:nth-of-type(1) { 
    animation-delay: 8s; 
    -webkit-animation-delay: 8s; 
} 

#backgroundchange div:nth-of-type(2) { 
    animation-delay: 6s; 
    -webkit-animation-delay: 6s; 
} 

#backgroundchange div:nth-of-type(3) { 
    animation-delay: 4s; 
    -webkit-animation-delay: 4s; 
} 

#backgroundchange div { 
    animation-name: backgroundchangeFadeInOut; 
    animation-timing-function: ease-in-out; 
    animation-iteration-count: infinite; 
    animation-duration: 8s; 
    -webkit-animation-name: backgroundchangeFadeInOut; 
    -webkit-animation-timing-function: ease-in-out; 
    -webkit-animation-iteration-count: infinite; 
    -webkit-animation-duration: 8s; 
} 

, 내가 첫 번째 배경 세트를 볼 수 있지만, 그것은으로 크로스 페이드 결코 다음.

+0

Banzay의 대답은 실제로 잘 작동하게! –

+0

기능을 처리하기위한 JavaScript 로직 및 제어 흐름은 어디에 있습니까? HTML과 CSS만으로는 HTML5/CSS/JavaScript의 진정한 동적 가능성은 충분하지 않습니다. 내 미묘함이 충분히 명확하지 않은 경우 편집 : HTML/CSS 조합은 동적 인 HTML5 : 자바 스크립트를 만드는 세 번째 중요한 요소가 부족합니다! –

+1

예루살렘, 나는 JS가 실제로이 목적을 위해 더 쉽게 만들어 준다는 것을 안다. 아직도 스타일이 더 많은 요소들에도 적용될 것이기 때문에 CSS에서 이것을해야한다. 귀하의 의견/답변 tho 주셔서 감사합니다! –

답변

0

는이 같은 매끄러운 원하십니까은?

여기 내 노트북에 작동하는 코드입니다 :

CSS :

.bgimg { 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    position: absolute; 
    background-repeat: no-repeat; 
    background-position: center center; 
    transform: scale(1); 
    -webkit-box-shadow: inset 4px 1px 77px 40px rgba(0,0,0,0.78); 
    -moz-box-shadow: inset 4px 1px 77px 40px rgba(0,0,0,0.78); 
    box-shadow: inset 4px 1px 77px 40px rgba(0,0,0,0.78); 
    top: 0; 
    left: 0; 
    height: 100%; 
    width: 100%; 
    background-image: url("../img/gallery/slonecz.jpg"); 
    animation-name: backgroundchangeFadeInOut; 
    animation-timing-function: ease-in-out; 
    animation-iteration-count: infinite; 
    animation-duration: 8s; 
    -webkit-animation-name: backgroundchangeFadeInOut; 
    -webkit-animation-timing-function: ease-in-out; 
    -webkit-animation-iteration-count: infinite; 
    -webkit-animation-duration: 8s; 
} 

@keyframes backgroundchangeFadeInOut { 
    0% { 
     background-image: url("../img/gallery/slonecz.jpg"); 
    } 
    50% { 
     background-image: url("../img/gallery/motyl.jpg"); 
    } 
    100% { 
     background-image: url("../img/gallery/slonecz.jpg"); 
    } 
} 

HTML :

<div class="bg"> 
    <div class="backgroundchange"> 
     <div class="bgimg" id="bg1"> 
      <div class="title centerV"> 
       <div> 
        <div class="text"> 
         <h1>Malarstwo</h1> 
         <p>Beaty Domanskiej</p> 
        </div> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 
+0

앞 페이지는 실제로 다음과 같이 보입니다. https://s29.postimg.org/abjplgptj/example.jpg 그리고 배경 이미지가 무한 루프로 다른 이미지로 페이드 아웃되도록하고 싶습니다. 코드 스 니펫을 실행할 때 몇 초마다 깜박이기 때문에 작동하는지 여부가 확실하지 않으며 초 단위로 코드를 구현하려고합니다. –

+0

답변을 변경했습니다. 저것을보세요 – Banzay

+0

와우, 당신은 코딩 레이싱 카 하하하입니다. 나는 그 대답을 게시 할 때 이것을 반쯤 만들었습니다 : P –

0

css @keyframe을 설정하지 않고는 애니메이션을 설정할 수 없습니다.

여기에 모든 애니메이션에 키 프레임을 추가하려면 아래 예는 다음과 같습니다

@-webkit-keyframes backgroundchangeFadeInOut{ 
      0% {transform: translateY(-100%); opacity: 0;} 
      80% {transform: translateY(40%);} 
      100% {transform: translateY(0%); opacity: 1;} 
     } 
+0

이미 설정된 키 프레임이 거의 없으며 제공 한 키 프레임을 구현했지만 여전히 효과가 없으며 어디서 실수했는지 궁금합니다. 내가 틀린 경우 정정해라. - 필자는 keyframes 코드를 내 css 파일에 넣을 수있다. 관련된 스타일 바로 뒤에 있어야 할 필요가 없다. –