2017-09-03 1 views
1

3 초마다 3 개의 이미지를 자동으로 회전시키고 싶지만 CSS3 애니메이션을 만들 수없는 슬라이더에서 작업했습니다.CSS3 만 계속 회전하는 슬라이더

이미지의 시작 상태를 불투명도 0으로 설정하면 페이드되고 절대 키 프레임에 응답하지 않습니다.

현재 jsfiddle에 내 코드를 볼 수 있습니다

: 주요 애니메이션 요소의 CSS는 CSS를 선 (28) 키 프레임에서 찾을 수 있습니다 https://jsfiddle.net/fchrisb/6wep1qL7/8/

@import url("https://fonts.googleapis.com/css?family=Just+Another+Hand"); 
 
body, 
 
html { 
 
    width: 100%; 
 
    height: 100%; 
 
    margin: 0; 
 
    font-family: 'Just Another Hand', cursive; 
 
    overflow-X: hidden; 
 
} 
 

 
.container { 
 
    margin: 0px auto; 
 
    position: relative; 
 
    width: 100%; 
 
    height: 0; 
 
    padding-bottom: 66%; 
 
    user-select: none; 
 
    background-color: #1c1c1c; 
 
    /* box-shadow: 0 11px 22px rgba(0, 0, 0, 0.2), 0 7px 7px rgba(0, 0, 0, 0.24); */ 
 
} 
 

 
.container input { 
 
    display: none; 
 
} 
 

 
.container .slide_img { 
 
    position: absolute; 
 
    width: 100%; 
 
    height: 100%; 
 
    z-index: -1; 
 
} 
 

 
.container div.slide_img { 
 
    animation: move_slide2 12s infinite; 
 
    //opacity: 0; 
 
} 
 

 
.container>div#one { 
 
    animation-delay: 0; 
 
} 
 

 
.container>div#two { 
 
    animation-delay: 4s; 
 
} 
 

 
.container>div#three { 
 
    animation-delay: 8s; 
 
} 
 

 
.container .slide_img a { 
 
    width: 100%; 
 
    height: 100% 
 
} 
 

 
.container .slide_img img { 
 
    width: inherit; 
 
    height: inherit; 
 
} 
 

 
.container .slide_img .prev, 
 
.container .slide_img .next { 
 
    width: 5%; 
 
    height: inherit; 
 
    position: absolute; 
 
    top: 0; 
 
    background-color: rgba(255, 82, 82, 0.2); 
 
    z-index: 99; 
 
    transition: .45s; 
 
    cursor: pointer; 
 
    text-align: center; 
 
} 
 

 
.container .slide_img .next { 
 
    right: 0; 
 
} 
 

 
.container .slide_img .prev { 
 
    left: 0; 
 
} 
 

 
.container .slide_img .prev:hover, 
 
.container .slide_img .next:hover { 
 
    transition: .3s; 
 
    background-color: rgba(255, 82, 82, 0.8); 
 
} 
 

 
.container .slide_img .prev span, 
 
.container .slide_img .next span { 
 
    position: absolute; 
 
    width: 0px; 
 
    height: 0px; 
 
    border: solid 20px; 
 
    top: 50%; 
 
    transform: translateY(-50%); 
 
} 
 

 
.container .slide_img .prev span { 
 
    border-color: transparent #fff transparent transparent; 
 
    right: 30%; 
 
} 
 

 
.container .slide_img .next span { 
 
    border-color: transparent transparent transparent #fff; 
 
    left: 30%; 
 
} 
 

 
.container #nav_slide { 
 
    width: 100%; 
 
    bottom: 12%; 
 
    height: 11px; 
 
    position: absolute; 
 
    text-align: center; 
 
    z-index: 99; 
 
    cursor: default; 
 
} 
 

 
.container #nav_slide .dots { 
 
    top: -5px; 
 
    width: 18px; 
 
    height: 18px; 
 
    margin: 0 3px; 
 
    position: relative; 
 
    border-radius: 100%; 
 
    display: inline-block; 
 
    background-color: rgba(0, 0, 0, 0.6); 
 
    transition: .4s; 
 
    cursor: pointer; 
 
} 
 

 
.container #nav_slide #dot1:hover { 
 
    background: #795548; 
 
} 
 

 
.container #nav_slide #dot2:hover { 
 
    background: #F44336; 
 
} 
 

 
.container #nav_slide #dot3:hover { 
 
    background: #2196F3; 
 
} 
 

 
#i1:checked~#one, 
 
#i2:checked~#two, 
 
#i3:checked~#three { 
 
    z-index: 9; 
 
    animation: scroll 1s ease-in-out; 
 
} 
 

 
#i1:checked~#nav_slide #dot1 { 
 
    background: #795548; 
 
} 
 

 
#i2:checked~#nav_slide #dot2 { 
 
    background: #F44336; 
 
} 
 

 
#i3:checked~#nav_slide #dot3 { 
 
    background: #2196F3; 
 
} 
 

 
@keyframes scroll { 
 
    0% { 
 
    opacity: .4; 
 
    } 
 
    100% { 
 
    opacity: 1; 
 
    } 
 
} 
 

 
@keyframes move_slide2 { 
 
    25% { 
 
    opacity: 1; 
 
    } 
 
    40% { 
 
    opacity: 0; 
 
    } 
 
} 
 

 
@media screen and (max-width: 800px) { 
 
    .container { 
 
    border: none; 
 
    width: 100%; 
 
    height: 0; 
 
    padding-bottom: 66%; 
 
    margin-top: 0px; 
 
    } 
 
    .container .slide_img .prev, 
 
    .container .slide_img .next { 
 
    width: 10%; 
 
    } 
 
    .container .slide_img .prev span, 
 
    .container .slide_img .next span { 
 
    border: solid 12px; 
 
    } 
 
    .container .slide_img .prev span { 
 
    border-color: transparent #fff transparent transparent; 
 
    } 
 
    .container .slide_img .next span { 
 
    border-color: transparent transparent transparent #fff; 
 
    } 
 
    .container #nav_slide .dots { 
 
    width: 12px; 
 
    height: 12px; 
 
    } 
 
}
<div class="container"> 
 
    <input type="radio" id="i1" name="images" checked/> 
 
    <input type="radio" id="i2" name="images" /> 
 
    <input type="radio" id="i3" name="images" /> 
 

 
    <div class="slide_img" id="one"> 
 

 
    <a href="https://marcomcentral.app.pti.com/Worth_Higgins_%26_Assoc.,_Inc./Access/catalog.aspx?uigroup_id=530928"><img src="https://worthhiggins.startlogic.com/wha/access/images/image_1c.jpg" style="border: 0;"></a> 
 

 
    <label class="prev" for="i4"><span></span></label> 
 
    <label class="next" for="i2"><span></span></label> 
 

 
    </div> 
 
    <div class="slide_img" id="two"> 
 

 
    <a href="https://marcomcentral.app.pti.com/Worth_Higgins_%26_Assoc.,_Inc./Access/catalog.aspx?uigroup_id=530928"><img src="https://worthhiggins.startlogic.com/wha/access/images/image_2c.jpg" style="border: 0;"></a> 
 

 
    <label class="prev" for="i1"><span></span></label> 
 
    <label class="next" for="i3"><span></span></label> 
 

 
    </div> 
 
    <div class="slide_img" id="three"> 
 
    <a href="https://marcomcentral.app.pti.com/Worth_Higgins_%26_Assoc.,_Inc./Access/catalog.aspx?uigroup_id=530928"><img src="https://worthhiggins.startlogic.com/wha/access/images/image_3c.jpg" style="border: 0;"></a> 
 

 
    <label class="prev" for="i2"><span></span></label> 
 
    <label class="next" for="i4"><span></span></label> 
 
    </div> 
 
    <div id="nav_slide"> 
 
    <label for="i1" class="dots" id="dot1"></label> 
 
    <label for="i2" class="dots" id="dot2"></label> 
 
    <label for="i3" class="dots" id="dot3"></label> 
 
    </div> 
 

 
</div>

- move_slide가 찾을 수 있습니다 css on line 137

답변

1

애니메이션이 서로 취소됩니다. 같은 줄에 설정하면 문제가 해결됩니다. 여기에 있습니다 animation: animationName1 2s infinite, animationName2 2s Infinite 기본적으로 두 애니메이션 사이에 쉼표 만 넣으면됩니다.

1

여기에있는 문제는 동일한 요소를 조작하여 동일한 속성을 조작하려고하는 두 개의 애니메이션을 실행하고 있다는 것입니다및 scroll은 각각 고유 한 방식으로 불투명도를 변경하려고합니다. scroll이 우선하므로 move_slide2은 무시됩니다.

move_slide2 애니메이션에는 다른 문제가 있지만 위에서 설명한 충돌을 해결하는 방법에 따라 해결해야합니다.

관련 문제