상세 컨텐츠

본문 제목

가로반응형웹페이지 만들기

웹표준·접근성

by 김일국 2015. 7. 26. 17:39

본문

페이지내의 문자, 이미지도 가로크기에 따라서 자동으로 커지는 기능을 Jssor 슬라이더 모듈로 구현해 보았습니다.

Jsoor 모듈과 jQuery모듈로 구분해서 구성해 보았습니다.

Jsoor 확인 URL: http://timespace.dothome.co.kr/response/full-width-slider.html

jQuery 확인 URL: http://timespace.dothome.co.kr/response/full-width-slider.jquery.html

위 소스는 MIT-LICENSE 를 따릅니다.

소스파일 

Jssor.Slider.zip

--------------------------------소스내용---------------------------------

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>가로반응형 슬라이더 - Jssor Slider</title>
</head>
<body style="padding:0px; margin:0px; font-family:Arial, Verdana;background-color:#fff;">
 <!-- 외부 CDN jquery 불러오기 -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
 <script type="text/javascript">var jQuery_new = $.noConflict(true);//제이쿼리 충돌방지로 $ -> jQuery_new로 대체</script>
 <!-- Jssor 슬라이더 모듈Start -->
    <script type="text/javascript" src="jssor.js"></script>
    <script type="text/javascript" src="jssor.slider.js"></script>
 <!-- Jssor 슬라이더 모듈End -->
    <script>
 jQuery_new(document).ready(function ($) {

            var _CaptionTransitions = [];
            _CaptionTransitions["L"] = { $Duration: 900, x: 0.6, $Easing: { $Left: $JssorEasing$.$EaseInOutSine }, $Opacity: 2 };
            _CaptionTransitions["R"] = { $Duration: 900, x: -0.6, $Easing: { $Left: $JssorEasing$.$EaseInOutSine }, $Opacity: 2 };
            _CaptionTransitions["T"] = { $Duration: 900, y: 0.6, $Easing: { $Top: $JssorEasing$.$EaseInOutSine }, $Opacity: 2 };
            _CaptionTransitions["B"] = { $Duration: 900, y: -0.6, $Easing: { $Top: $JssorEasing$.$EaseInOutSine }, $Opacity: 2 };
            _CaptionTransitions["ZMF|10"] = { $Duration: 900, $Zoom: 11, $Easing: { $Zoom: $JssorEasing$.$EaseOutQuad, $Opacity: $JssorEasing$.$EaseLinear }, $Opacity: 2 };
            _CaptionTransitions["RTT|10"] = { $Duration: 900, $Zoom: 11, $Rotate: 1, $Easing: { $Zoom: $JssorEasing$.$EaseOutQuad, $Opacity: $JssorEasing$.$EaseLinear, $Rotate: $JssorEasing$.$EaseInExpo }, $Opacity: 2, $Round: { $Rotate: 0.8} };
            _CaptionTransitions["RTT|2"] = { $Duration: 900, $Zoom: 3, $Rotate: 1, $Easing: { $Zoom: $JssorEasing$.$EaseInQuad, $Opacity: $JssorEasing$.$EaseLinear, $Rotate: $JssorEasing$.$EaseInQuad }, $Opacity: 2, $Round: { $Rotate: 0.5} };
            _CaptionTransitions["RTTL|BR"] = { $Duration: 900, x: -0.6, y: -0.6, $Zoom: 11, $Rotate: 1, $Easing: { $Left: $JssorEasing$.$EaseInCubic, $Top: $JssorEasing$.$EaseInCubic, $Zoom: $JssorEasing$.$EaseInCubic, $Opacity: $JssorEasing$.$EaseLinear, $Rotate: $JssorEasing$.$EaseInCubic }, $Opacity: 2, $Round: { $Rotate: 0.8} };
            _CaptionTransitions["CLIP|LR"] = { $Duration: 900, $Clip: 15, $Easing: { $Clip: $JssorEasing$.$EaseInOutCubic }, $Opacity: 2 };
            _CaptionTransitions["MCLIP|L"] = { $Duration: 900, $Clip: 1, $Move: true, $Easing: { $Clip: $JssorEasing$.$EaseInOutCubic} };
            _CaptionTransitions["MCLIP|R"] = { $Duration: 900, $Clip: 2, $Move: true, $Easing: { $Clip: $JssorEasing$.$EaseInOutCubic} };

            var options = {
                $FillMode: 2,                                       //[Optional] 슬라이드에 이미지를 채우는 방법, 0 스트레칭, 1, 2 커버, 4 실제 크기, 5 작은 대형 이미지, 실제 크기에 포함 (전체 슬라이드를 가로 세로 비율을 유지하고 커버) (가로 세로 비율을 유지하고 모든 내부 슬라이드를 넣어) 포함 이미지, 기본값은 0입니다.
                $AutoPlay: false,                                    //[Optional] 자동 재생할지 여부, 슬라이드 쇼를 사용하려면,이 옵션은, 기본값은 false true로 설정해야합니다.
                $AutoPlayInterval: 4000,                            //[Optional] 슬라이더가 자동 재생의 경우 이전이 정지 이후 (밀리 초) 간격이 다음 슬라이드 이동, 기본값은 3000입니다.
                $PauseOnHover: 1,                                   //[Optional] 일시 정지 여부 때 마우스를 통해 슬라이더는 자동 재생, 0없이 일시 정지, 바탕 화면 1 일시 정지, 터치 장치에 대한 2 일시 정지, 바탕 화면과 터치 장치에 대한 3 일시 정지, 바탕 화면 4 동결, 터치 장치에 대한 8 동결, 12 동결 인 경우 바탕 화면과 터치 장치, 기본값은 1입니다.

                $ArrowKeyNavigation: false,                  //[Optional] 키보드 (화살표 키) 탐색을 할 수 있습니다 여부, 기본값은 false입니다.
                $SlideEasing: $JssorEasing$.$EaseOutQuint,          //[Optional] 왼쪽 애니메이션 권리를 완화 지정, 기본값은 $ JssorEasing $. $ EaseOutQuad입니다.
                $SlideDuration: 800,                                //[Optional] (밀리 초) 슬라이드에 대한 기본 시간 (와이프)를 지정, 기본값은 500입니다.
                $MinDragOffsetToSlide: 20,                          //[Optional] 최소 드래그 슬라이드를 트리거 오프셋, 디폴트 값은 20입니다.
                //$SlideWidth: 600,                                 //[Optional] 픽셀의 모든 슬라이드의 폭, 기본값은 '슬라이드' 컨테이너의 폭입니다.
                //$SlideHeight: 300,                                //[Optional] 픽셀의 모든 슬라이드의 높이, 기본값은 '슬라이드'컨테이너의 높이입니다.
                $SlideSpacing: 0,                      //[Optional] 픽셀 단위로 각 슬라이드 사이의 공간, 기본값은 0입니다.
                $DisplayPieces: 1,                                  //[Optional] 표시 조각의 수, 디폴트 값은 1이다. (값이 1보다 크게 설정된 경우 슬라이드 쇼가 중지 됨)
                $ParkingPosition: 0,                                //[Optional] 슬라이드 오프셋(offset) 위치 (이 옵션은 슬라이드 쇼 사용 안할 경우에만) 기본값은 0.
                $UISearchMode: 1,                                   //[Optional] UI 구성 요소를 검색 할 수있는 방법 (0 parellel, 1 재귀, 기본값은 1)은 (컨테이너, 로딩 화면, 네비게이터 컨테이너, 화살표 네비게이터 컨테이너 등 썸네일 네비게이터 컨테이너 슬라이드).
                $PlayOrientation: 1,                                //[Optional] 방향이 슬라이드를 재생, 가로, 1, 2, 수직, 5 역 가로, 6 수직 역 (자동 재생, 탐색), 기본값은 1입니다
                $DragOrientation: 0,                                //[Optional] 방향은 기본값은 1 ($DisplayPieces이 1보다 큰 경우, 또는 위치가 0이 아닌 경우는 $DragOrientation $PlayOrientation와 동일해야합니다)이며, 하나의 슬라이드, 0 드래그없음, 1 가로, 2, 수직, 3 드래그

                   $HWA: false,    //[Optional] 아이폰4에서 에러 나서 추가

                $CaptionSliderOptions: {                            //[Optional] 애니메이션 갭션을 지정하는 방법의 옵션
                    $Class: $JssorCaptionSlider$,                   //[Required] 애니메이션을 캡션 인스턴스를 만들려는 클래스
                    $CaptionTransitions: _CaptionTransitions,       //[Required] 갭션의배열은 갭션을 재생 전환, jssor 슬라이드 쇼 전환 빌더에서 캡션 전환 섹션을 참조하십시오.
                    $PlayInMode: 1,                                 //[Optional] 0 없음 (NO PLAY), 1 연결패턴(주 슬라이드 후에 사라진다) 3 연결패턴 (모든 캡션 애니메이션을 합치고, 주 슬라이드 후 사라진다.),기본 값은 1
                    $PlayOutMode: 3                                 //[Optional] 0 없음 (NO PLAY), 1 연결패턴(주 슬라이드 전에 사라진다), 3 연결패턴 (모든 캡션 애니메이션을 합치고, 주 슬라이드 전에 사라진다),기본 값은 1
                },

                $BulletNavigatorOptions: {                          //[Optional] 이 옵션은 네비게이터를 사용하거나 사용하지 않으려면 지정한다.
                    $Class: $JssorBulletNavigator$,                 //[Required] 이 클래스 페이징네비게이션 인스턴스를 만들려면 지정.
                    $ChanceToShow: 0,                               //[Required] 0 숨김, 1 마우스오버표시, 2 항상표시
                    $AutoCenter: 1,                                 //[Optional] 부모 컨테이너에 자동 센터 네비게이터, 0 없음, 1 수평, 수직 2, 3 모두, 기본값은 0입니다
                    $Steps: 1,                                      //[Optional] 각 페이지네비 요청에 대해 갈 단계, 기본 값은 1이다.
                    $Lanes: 1,                                      //[Optional] 항목을 정렬하기 위해 차선을 지정, 기본값은 1입니다.
                    $SpacingX: 8,                                   //[Optional] 픽셀의 각 항목 사이의 수평 공간, 기본값은 0입니다.
                    $SpacingY: 8,                                   //[Optional] 픽셀의 각 항목 사이의 수직 공간은, 기본값은 0입니다.
                    $Orientation: 1                                 //[Optional] 네비게이터 방향, 1수평방향, 2수직, 기본값은 1입니다
                },

                $ArrowNavigatorOptions: {                       //[Optional] 이 옵션은 화살표를 사용하거나 사용하지 않으려면 지정한다.
                    $Class: $JssorArrowNavigator$,              //[Requried] 이 클래스 화살표 인스턴스를 만들려면 지정.
                    $ChanceToShow: 0,                               //[Required] 0 숨김, 1 마우스오버표시, 2 항상표시
                    $AutoCenter: 2,                                 //[Optional] 부모 컨테이너에 자동 센터 네비게이터, 0 없음, 1 수평, 수직 2, 3 모두, 기본값은 0입니다
                    $Steps: 1                                       //[Optional] 각 페이지네비 요청에 대해 갈 단계, 기본 값은 1이다.
                }
            };

            var jssor_slider1 = new $JssorSlider$("slider1_container", options);
   var jssor_slider2 = new $JssorSlider$("slider2_container", options);

            //반응형 코드Start
            //화면사이즈에 따라 슬라이드개체가 변화되는것을 원하지 않는다면 이 코드를 삭제하면 됩니다.
            function ScaleSlider() {
                var bodyWidth = document.body.clientWidth;
                if (bodyWidth){
                    jssor_slider1.$ScaleWidth(Math.min(bodyWidth, 3920));//1920
     jssor_slider2.$ScaleWidth(Math.min(bodyWidth, 3920));//1920
                }else{
                    window.setTimeout(ScaleSlider, 30);
    }
            }
            ScaleSlider();
   
            $(window).bind("load", ScaleSlider);
            $(window).bind("resize", ScaleSlider);
            $(window).bind("orientationchange", ScaleSlider);
            //responsive code end
        });
    </script>
    <!-- Jssor 슬라이더1 -->
    <!-- 이곳의 width,height 값이 반응형 이미지의 가로/세로 크기가 된다. height: 500px; -->
    <div id="slider1_container" style="position: relative; margin: 0 auto;height: 500px;
        top: 0px; left: 0px; width: 1300px; overflow: hidden;">
        <!-- Loading 대기화면 -->
        <div u="loading" style="position: absolute; top: 0px; left: 0px;">
            <div style="filter: alpha(opacity=70); opacity: 0.7; position: absolute; display: block;
                top: 0px; left: 0px; width: 100%; height: 100%;">
            </div>
            <div style="position: absolute; display: block; background: url(./image/loading.gif) no-repeat center center;
                top: 0px; left: 0px; width: 100%; height: 100%;">
            </div>
        </div>
        <!-- 이곳의 width,height 값이 반응형 이미지의 가로/세로 크기가 된다. cursor: move; height: 500px;-->
        <div u="slides" style="position: absolute; left: 0px; top: 0px; width: 1300px;height: 500px;
            overflow: hidden;">
            <div>
                <img u="image" src="./image/1920/red.jpg" />
                <div u="caption" t="NO" t3="RTT|2" r3="137.5%" du3="3000" d3="500" style="position: absolute; width: 445px; height: 300px; top: 100px; left: 600px;">
                    <img src="./image/new-site/c-phone.png" style="position: absolute; width: 445px; height: 300px; top: 0px; left: 0px;" />
                    <img u="caption" t="CLIP|LR" du="4000" t2="NO" src="./image/new-site/c-jssor-slider.png" style="position: absolute; width: 102px; height: 78px; top: 70px; left: 130px;" />
                    <img u="caption" t="ZMF|10" t2="NO" src="./image/new-site/c-text.png" style="position: absolute; width: 80px; height: 53px; top: 153px; left: 163px;" />
                    <img u="caption" t="RTT|10" t2="NO" src="./image/new-site/c-fruit.png" style="position: absolute; width: 140px; height: 90px; top: 60px; left: 220px;" />
                    <img u="caption" t="T" du="4000" t2="NO" src="./image/new-site/c-navigator.png" style="position: absolute; width: 200px; height: 155px; top: 57px; left: 121px;" />
                </div>
                <div u="caption" t="RTT|2" r="-75%" du="1600" d="2500" t2="NO" style="position: absolute; width: 470px; height: 220px; top: 120px; left: 650px;">
                    <img src="./image/new-site/c-phone-horizontal.png" style="position: absolute; width: 470px; height: 220px; top: 0px; left: 0px;" />
                    <img u="caption" t3="MCLIP|L" du3="2000" src="./image/new-site/c-slide-1.jpg" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" />
                    <img u="caption" t="MCLIP|R" du="2000" t2="NO" src="./image/new-site/c-slide-3.jpg" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" />
                    <img u="caption" t="RTTL|BR" x="500%" y="500%" du="1000" d="-3000" r="-30%" t3="L" x3="70%" du3="1600" src="./image/new-site/c-finger-pointing.png" style="position: absolute; width: 257px; height: 300px; top: 80px; left: 200px;" />
                    <img src="./image/new-site/c-navigator-horizontal.png" style="position: absolute; width: 379px; height: 213px; top: 4px; left: 45px;" />
                </div>
                <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;
                    text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;
                        color: #FFFFFF;">반응형 문자 처리1
                </div>
                <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;
                    text-align: left; line-height: 36px; font-size: 30px;
                        color: #FFFFFF;">
                        반응형 문자 처리1반응형 문자 처리1반응형 문자 처리1반응형 문자 처리1반응형 문자 처리1반응형 문자 처리1
                </div>
            </div>
            <div>
                <img u="image" src="./image/1920/purple.jpg" />
                <img src="./image/new-site/c-phone.png" style="position: absolute; width: 445px; height: 300px; top: 100px; left: 600px; background-color: transparent;" />
                <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;
                    text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;
                        color: #FFFFFF;">반응형 문자 처리2
                </div>
                <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;
                    text-align: left; line-height: 36px; font-size: 30px;
                        color: #FFFFFF;">
                        반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2
                </div>
            </div>
            <div>
                <img u="image" src="./image/1920/blue.jpg" />
                <img src="./image/new-site/c-phone.png" style="position: absolute; width: 445px; height: 300px; top: 100px; left: 600px; background-color: transparent;" />
                <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;
                    text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;
                        color: #FFFFFF;">반응형 문자 처리3
                </div>
                <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;
                    text-align: left; line-height: 36px; font-size: 30px;
                        color: #FFFFFF;">
                        반응형 문자 처리3반응형 문자 처리3반응형 문자 처리3반응형 문자 처리3반응형 문자 처리3반응형 문자 처리3
                </div>
            </div>
        </div>
        <!--슬라이드 페이징네비게이션 불렛아이콘 영역 CSS -->
        <style>
            /* jssor slider 불렛 페이징 스킨 css */
            /*
            .jssorb21 div           (normal)
            .jssorb21 div:hover     (normal mouseover)
            .jssorb21 .av           (active)
            .jssorb21 .av:hover     (active mouseover)
            .jssorb21 .dn           (mousedown)
            */
            .jssorb21 {
                position: absolute;
            }
            .jssorb21 div, .jssorb21 div:hover, .jssorb21 .av {
                position: absolute;
                /* 불렛 개체 사이즈 */
                width: 19px;
                height: 19px;
                text-align: center;
                line-height: 19px;
                color: white;
                font-size: 12px;
                background: url(./image/b21.png) no-repeat;
                overflow: hidden;
                cursor: pointer;
            }
            .jssorb21 div { background-position: -5px -5px; }
            .jssorb21 div:hover, .jssorb21 .av:hover { background-position: -35px -5px; }
            .jssorb21 .av { background-position: -65px -5px; }
            .jssorb21 .dn, .jssorb21 .dn:hover { background-position: -95px -5px; }
        </style>
        <!-- #bullet 아이콘 출력 영역 -->
        <div u="navigator" class="jssorb21" style="bottom: 26px; right: 6px;">
            <!-- 블렛 아이콘 출력 아이콘 -->
            <div u="prototype"></div>
        </div>
        <!-- #bullet 아이콘 출력 영역// -->
       
        <!--#좌우 화살표 영역 -->
        <style>
            /* jssor slider 화살표 navigator 스킨 css */
            /*
            .jssora21l                  (normal)
            .jssora21r                  (normal)
            .jssora21l:hover            (normal mouseover)
            .jssora21r:hover            (normal mouseover)
            .jssora21l.jssora21ldn      (mousedown)
            .jssora21r.jssora21rdn      (mousedown)
            */
            .jssora21l, .jssora21r {
                display: block;
                position: absolute;
                /* 화살표 사이즈 */
                width: 55px;
                height: 55px;
                cursor: pointer;
                background: url(./image/a21.png) center center no-repeat;
                overflow: hidden;
            }
            .jssora21l { background-position: -3px -33px; }
            .jssora21r { background-position: -63px -33px; }
            .jssora21l:hover { background-position: -123px -33px; }
            .jssora21r:hover { background-position: -183px -33px; }
            .jssora21l.jssora21ldn { background-position: -243px -33px; }
            .jssora21r.jssora21rdn { background-position: -303px -33px; }
        </style>
        <!-- Arrow Left -->
        <span u="arrowleft" class="jssora21l" style="top: 123px; left: 8px;">
        </span>
        <!-- Arrow Right -->
        <span u="arrowright" class="jssora21r" style="top: 123px; right: 8px;">
        </span>
        <!--#좌우 화살표 영역// -->
        <a style="display: none" href="http://www.jssor.com">Bootstrap Slider</a>
    </div>
 <!-- 이곳의 width,height 값이 반응형 이미지의 가로/세로 크기가 된다. cursor: move; -->
 <div id="slider2_container" style="position: relative; margin: 0 auto;
 top: 0px; left: 0px; width: 1300px; height: 500px; overflow: hidden;">
  <!-- 이곳의 width,height 값이 반응형 이미지의 가로/세로 크기가 된다. cursor: move; -->
  <div u="slides" style="position: absolute; left: 0px; top: 0px; width: 1300px;
   height: 500px; overflow: hidden;">
   <div>
    <img u="image" src="./image/1920/purple.jpg" />
    <img src="./image/new-site/c-phone.png" style="position: absolute; width: 445px; height: 300px; top: 100px; left: 600px; background-color: transparent;" />
    <div style="position: absolute; width: 480px; height: 120px; top: 30px; left: 30px; padding: 5px;
     text-align: left; line-height: 60px; text-transform: uppercase; font-size: 50px;
      color: #FFFFFF;">반응형 문자 처리2
    </div>
    <div style="position: absolute; width: 480px; height: 120px; top: 300px; left: 30px; padding: 5px;
     text-align: left; line-height: 36px; font-size: 30px;
      color: #FFFFFF;">
      반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2반응형 문자 처리2
    </div>
   </div>
  </div>
 </div>
</body>
</html>

Jssor.Slider.zip
0.36MB

관련글 더보기

댓글 영역