2016-06-11 4 views
0

저는 이오닉 프레임 워크가있는 응용 프로그램에서 작업하고 있으며 CSS에서는 아직 초보자입니다. 타이머가있는 이미지 슬라이더를 만들었지 만 크기는 고정되어 있습니다. 그러나 화면 크기와 해상도에 따라 변경하고 싶습니다.div 화면 크기에 따라 달라집니다.

있는 style.css

내가 그런 일 한에서

<ion-content> 
    <div class="container"> 
     <div id="content-slider"> 
      <div id="slider"> 
       <div id="mask"> 
        <ul> 
         <li id="first" class="firstanimation"> 
          <a href=#><img src="../img/coffe_and_sweet_sale.jpg"/></a> 
          <div class="tooltip"><h1>text 1</h1></div> 
         </li> 
         <li id="second" class="secondanimation"> 
          <a href="#"><img src="../img/pizza_sale.png"/></a> 
          <div class="tooltip"><h1>text 2</h1></div> 
         </li> 
         <li id="third" class="thirdanimation"> 
          <a href="#"><img src="../img/sandwich_sale.jpg"/></a> 
          <div class="tooltip"><h1>text 3</h1></div> 
         </li> 
        </ul> 
       </div> 
      </div> 
     </div> 
    </div> 
    </ion-content> 

:

은 HTML 콘텐츠입니다 그래서 지금

#slider{ 
    background: #000; 
    border: 5px solid #eaeaea; 
    box-shadow: 1px 1px 5px rgba(0,0,0,0.7); 
    height: 320px; 
    width: 680px; 
    margin: 40px auto 0; 
    overflow: visible; 
    position: relative; 
} 

#mask{ 
    overflow: hidden; 
    height: 310px; 
} 

#slider ul{ 
    margin: 0; 
    padding: 0; 
    position: relative; 
} 

#slider li{ 
    width: 680px; 
    height: 320px; 
    position: absolute; 
    top: -325px; 
    list-style: none; 
} 

#slider img{ 
    width: 680px; 
    height: 320px; 
} 

그것을 메신저 보여줍니다. 그러나 그것은 어떤 스크린에도 맞지 않습니다.

내가 슬라이더 애니메이션의 스타일을 추가 해요 1

편집 :

#slider li.firstanimation{ 
    animation: cycle 24s linear infinite; 
} 

#slider li.secondanimation{ 
    animation: cycletwo 24s linear infinite; 
} 
#slider li.thirdanimation{ 
    animation: cyclethree 24s linear infinite; 
} 

@keyframes cycle{ 
    0% {top: 0px;} 
    3.33% {top: 0px;} 
    26.64% {top:0px; opacity: 1; z-index: 0;} 
    29.97% {top: 325px; opacity: 0; z-index: 0;} 
    30.97% {top:-325px; opacity: 0; z-index: 0;} 
    93.34% {top:-325px; opacity: 0; z-index: 0;} 
    96.67% {top: -325px; opacity: 0; } 
    100% {top: 0px; opacity: 1;} 
} 

@keyframes cycletwo{ 
    0% {top: -325px; opacity: 0;} 
    26.64% {top: -325px; opacity: 0} 
    29.97% {top:0px; opacity: 1;} 
    33.3% {top: 0px; opacity: 1;} 
    59.94% {top: 0px; opacity: 1; z-index: 0;} 
    63.27% {top: 325px; opacity: 0; z-index: 0;} 
    64.27% {top: -325px; opacity: 0; z-index: -1; } 
    100% {top: -325px; opacity: 0; z-index: -1;} 
} 

@keyframes cyclethree{ 
    0% {top: -325px; opacity: 0;} 
    59.94% {top: -325px; opacity: 0;} 
    63.27% {top:0px; opacity: 1;} 
    66.6% {top: 0px; opacity: 1;} 
    93.24% {top: 0px; opacity: 1;} 
    96.57% {top: 325px; opacity: 0; z-index: 0;} 
    97.57% {top: -325px; opacity: 0; z-index: -1;} 
    100% {top: -325px; opacity: 0; z-index: -1;} 
} 

#slider .tooltip{ 
    background: rgba(0,0,0,0.7); 
    width: 450px; 
    height; 60px; 
    position: relative; 
    bottom: 85px; 
} 

#slider .tooltip h1{ 
    color: #fff; 
    font-size: 24px; 
    font-weight: 300; 
    line-height: 60px; 
    padding: 0 0 0 10px; 
} 

#slider .tooltip { 
    transition: all 0.3 ease-in-out; 
} 
+0

* 어떤 화면에도 * 맞지 않습니까? 그러나 대부분의 컴퓨터에서는 잘 동작 할 것입니다. 그러나 모바일에서는 축소 형 (축소)이거나 스크롤바가있는 뷰포트 외부로 이동합니다 (뷰포트 메타 태그에 따라 다름). 어쨌든 절대 픽셀 대신 % 단위 또는 % 단위를 사용하십시오. 뷰포트 단위 ('vh','vw'). 높이가 작동하려면 ** 반드시 html과 body로 높이를 정의해야합니다 :'html, body {height : 100 %; }' – Aziz

+0

이것을 위해 jsfiddle을 만들 수 있습니까? – frnt

답변

1

높이에 대한 미디어 쿼리를 하나 추가했습니다. Here's 뭔가를 변경하려면 mediaquery 링크를 클릭하십시오.

슬라이드의 경우 세 번째 슬라이드와 첫 번째 슬라이드 사이에 문제가 해결되었습니다. 빈 슬라이드가 있습니다. 그것이 디자인에 의한 것인지 아닌지 확실하지 않았습니다. 필요하면 고칠 수 있기를 바랍니다.

#slider{ 
    background: #000; 
    border: 5px solid #eaeaea; 
    box-shadow: 1px 1px 5px rgba(0,0,0,0.7); 
    height: 320px; 
    width: 80%; 
    max-width: 680px; 
    margin: 40px auto 0; 
    overflow: visible; 
    position: relative; 
    } 

    #mask{ 
    overflow: hidden; 
    height: 310px; 
    } 

    #slider ul{ 
    margin: 0; 
    padding: 0; 
    height: 320px; 
    width: inherit; 
    position: relative; 
    } 

    #slider a{ 
    width: 100%; 
    height: 100%; 
    } 

    #slider li{ 
    width: inherit; 
    height: 320px; 
    position: absolute; 
    top: 100px; 
    list-style: none; 
    } 

    #slider img{ 
    width: 100%; 
    height: 320px; 
    } 
    #slider li.firstanimation{ 
    animation: cycle 24s linear infinite; 
    } 

    #slider li.secondanimation{ 
    animation: cycletwo 24s linear infinite; 
    } 
    #slider li.thirdanimation{ 
    animation: cyclethree 24s linear infinite; 
    } 

    @keyframes cycle{ 
    0% {top: 0px;} 
    3.33% {top: 0px;} 
    26.64% {top:0px; opacity: 1; z-index: 0;} 
    29.97% {top: 325px; opacity: 0; z-index: 0;} 
    30.97% {top:-325px; opacity: 0; z-index: 0;} 
    93.34% {top:-325px; opacity: 0; z-index: 0;} 
    96.67% {top: -325px; opacity: 0; } 
    100% {top: 0px; opacity: 1;} 
    } 

    @keyframes cycletwo{ 
    0% {top: -325px; opacity: 0;} 
    26.64% {top: -325px; opacity: 0} 
    29.97% {top:0px; opacity: 1;} 
    33.3% {top: 0px; opacity: 1;} 
    59.94% {top: 0px; opacity: 1; z-index: 0;} 
    63.27% {top: 325px; opacity: 0; z-index: 0;} 
    64.27% {top: -325px; opacity: 0; z-index: -1; } 
    100% {top: -325px; opacity: 0; z-index: -1;} 
    } 

    @keyframes cyclethree{ 
    0% {top: -325px; opacity: 0;} 
    59.94% {top: -325px; opacity: 0;} 
    63.27% {top:0px; opacity: 1;} 
    66.6% {top: 0px; opacity: 1;} 
    93.24% {top: 0px; opacity: 1;} 
    96.57% {top: 325px; opacity: 0; z-index: 0;} 
    97.57% {top: -325px; opacity: 0; z-index: -1;} 
    100% {top: -325px; opacity: 0; z-index: -1;} 
    } 

    #slider .tooltip{ 
    background: rgba(0,0,0,0.7); 
    width: 60%; 
    height; 60px; 
    position: relative; 
    bottom: 85px; 
    } 

    #slider .tooltip h1{ 
    color: #fff; 
    font-size: 24px; 
    font-weight: 300; 
    line-height: 60px; 
    padding: 0 0 0 10px; 
    } 

    #slider .tooltip { 
    transition: all 0.3 ease-in-out; 
    } 

    @media screen and (max-height: 380px){ 
    #slider{ 
     height: 200px; 
    } 

    #mask{ 
     height:190px; 
    } 

    #slider img{ 
     height:190px; 
    } 

    #slider li{ 
     height:190px; 
    } 

    #slider ul{ 
     height:190px; 
    } 

    #slider .tooltip{ 
     bottom: 80px; 
    }   
    } 
+0

이제 너비가 화면 크기에 반응 하나 높이가 표시되지 않고 애니메이션이 제대로 작동하지 않습니다. 첫 번째 이미지 만 몇 초 동안 표시되고 검은 색 슬라이더가 몇 초 이상 표시됩니다 첫 번째 이미지 반환 등, – kitsuneFox

+0

일반적으로 높이를 유지하지만 원하는 경우 다른 화면 범위에 대해 서로 다른 높이를 구성 할 수 있습니다. 또한 내가 그것을 테스트하고 더 나은 솔루션을 제공 할 수 있도록 슬라이더에 대한 코드를 얻을 수 있습니다. – a1626

+0

자, 이제 좋습니다. 코드를 살펴보고 사소한 것들을 변경 하겠지만 모든 것이 훌륭합니다! 그건 그렇고, 제발 CSS를 배우는 법을 제게 제안 해주세요. 나는 경험 많은 프로그래머이지만 CSS는 항상 나의 가장 약한 링크였습니다. 나는 그것을 고치고 싶다. – kitsuneFox

1

변경

#slider img{ 
    max-width:100%; 
    display:block; 
    width:100%; 
} 

은 이미지의 절대 값을 제거합니다.

+0

화면이 바뀌면 전체 슬라이더가 바뀌기를 원합니다.이 경우 – kitsuneFox

+0

같은 슬라이더를 사용할 수 있습니다. – a1626

+0

그리고 마스크는 어떨까요? – kitsuneFox

관련 문제