Bomb Kirby Running

웹 페이지 만들기

슬라이드 유형 레이아웃 웹페이지 만들기

^. ̫ .^ 2023. 3. 15. 17:34

728x90

 

수업 시간에 위와 같은 카드유형레이아웃을 똑같이 웹 페이지로 구현해 보았습니다.

슬라이드 유형은 보시다시피 사진과 문자를 슬라이드 형식으로 넘길 수 있는 구조로 되어있는 유형입니다. 

<!DOCTYPE html>
<html lang="ko">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>슬라이드 유형01</title>
    <link href="https://webfontworld.github.io/NexonLv1Gothic/NexonLv1Gothic.css" rel="stylesheet">

    <style>
        /* reset */
        * {
            margin: 0;
            padding: 0;
        }
        a {
            text-decoration: none;
            color: #000;
        }
        h1,h2,h3,h4,h5,h6 {
            font-weight: normal;
        }
        img {
            vertical-align: top;
            width: 100%;
        }
        .blind {
            position:absolute;
            clip:rect(0 0 0 0);
            width:1px;
            height:1px;
            margin:-1px;
            overflow:hidden
        }
        .mt10 {margin-top: 10px !important;}
        .mt20 {margin-top: 20px !important;}
        .mt30 {margin-top: 30px !important;}
        .mt40 {margin-top: 40px !important;}
        .mt50 {margin-top: 50px !important;}
        .mt60 {margin-top: 60px !important;}
        .mt70 {margin-top: 70px !important;}
        
        .mb10 {margin-bottom: 10px !important;}
        .mb20 {margin-bottom: 20px !important;}
        .mb30 {margin-bottom: 30px !important;}
        .mb40 {margin-bottom: 40px !important;}
        .mb50 {margin-bottom: 50px !important;}
        .mb60 {margin-bottom: 60px !important;}
        .mb70 {margin-bottom: 70px !important;}
        /* common */
        .container {
            width: 1160px;
            margin: 0 auto;
            padding: 0 20px;
            /* background-color: rgba(0, 0, 0, 0.1); */
        }
        .nexon {
            font-family: 'NexonLv1Gothic';
            font-weight: 400;
        }
        .section {
            padding: 120px 0;
            
        }
        .section.center {
            text-align: center;
        }
        .section__small {
            font-size: 14px;
            border-radius: 50px;
            background-color: #0083FD;
            color: #fff;
            padding: 1px 23px;
            text-transform: uppercase;
            margin-bottom: 20px;
            display: inline-block;
        }
        .section__h2 {
            font-size: 50px;
            font-weight: 400;
            margin-bottom: 30px;
            line-height: 1;
        }
        .section__desc {
            font-size: 22px;
            color: #666;
            margin-bottom: 70px;
            font-weight: 300;
            line-height: 1.5;
        }
        /* sild__wrap */

        .slider__inner .slider {
            height: 600px;
            background-image: url(../assets/image/slideType_01_01.jpg);
            background-size: cover;
            background-repeat: no-repeat;
            background-position: center;
            position: relative;
            z-index: 1;
        }
        .slider__inner .slider::after {
            content: '';
            width: 100%;
            height: 100%;
            background-color:  rgba(224, 217, 88, 0.1);
            position: absolute;
            left: 0;
            top: 0;
            z-index: -1;
        }
        .slider__info {
            padding: 100px 0;
        }
        .slider__info .small {
            display: inline-block;
            padding: 1px 30px;
            background-color: #fff;
            color: #000;
            font-size: 16px;
            border-radius: 50px;
            text-transform: uppercase;
            margin-bottom: 10px;
        }
        .slider__info .title {
            font-size: 80px;
            color: #fff;
            margin-bottom: 40px;
            margin-left: -5px;
        }
        .slider__info .desc {
            font-size: 18px;
            line-height: 1.5;
            color: #fff;
            width: 50%;
            word-break: keep-all;
        }
        .slider__info .btn {
            margin-top: 100px;
        }
        .slider__info .btn a {
            width: 180px;
            background: #fff;
            font-size: 16px;
            display: inline-block;
            text-align: center;
            padding: 12px 0;
            margin-right: 4px;
        }
        .slider__info .btn a:last-child {
            background-color: #000;
            color: #fff;
        }
        .slider__arrow a {
            position: absolute;
            top: 50%;
            background-image: url(../assets/image/icon_main.svg);
            background-size: 500px;
            width: 30px;
            height: 56px;
            display: block;
            margin-top: -28px;
        }
        .slider__arrow a:first-child {   
            left: 20px;
        }
        .slider__arrow a:last-child {
            right: 20px;
            background-position: -52px 0;
        }
        .slider__dot {
            position: absolute;
            left: 50%;
            bottom: 20px;
            transform: translateX(-50%);
        }
        .slider__dot a {
           width: 16px;
           height: 16px;
           display: inline-block;
           background-image: url(../assets/image/icon_main.svg);
           background-size: 500px;
           margin: 0 3px;   
        }
        .slider__dot a.dot {
            background-position: -101px -1px;
        }
        .slider__dot a.active {
            background-position: -121px -1px;
        }
        .slider__dot a.play {
            background-position: -141px -1px;
        }
        .slider__dot a.stop {
            background-position: -161px -1px;
        }
        @media only screen and (-webkit-min-device-pixel-ratio: 2),
            only screen and (min-device-pixel-ratio: 2),
            only screen and (min-resolution: 2dppx) {
                .slider__inner .slider {
                    background-image: url(../assets/image/slideType_01_01@2x.jpg);
                }   
            }
    </style>
</head>
<body>
    <section class="slider__wrap nexon">
        <h2 class="blind">메인 슬라이드 영역</h2>
        <div class="slider__inner">
            <div class="slider">
                <div class="slider__info container">
                    <span class="small">event</span>
                    <h1 class="title">냥집사들의 커뮤니티 Catt</h1>
                    <p class="desc">고양이 케어, 고양이 목욕,고양이 산책. 고양이 패션, 집사 커뮤니티
                        고양이와 관련된 모든 정보를 공유합니다.</p>
                    <div class="btn">
                        <a href="#">자세히 보기</a>
                        <a href="#">상담 신청</a>
                    </div>
                </div>
                <div class="slider__arrow">
                    <a href="#"><span class="blind">이전 이미지</span></a>
                    <a href="#"><span class="blind">다음 이미지</span></a>
                </div>
                <div class="slider__dot">
                    <a href="#" class="dot active"><span class="blind">첫번째 이미지</span></a>
                    <a href="#" class="dot"><span class="blind">두번째 이미지</span></a>
                    <a href="#" class="dot"><span class="blind">세번째 이미지</span></a>
                    <a href="#" class="play"><span class="blind">플레이</span></a>
                    <a href="#" class="stop"><span class="blind">정지</span></a>
                </div>
            </div>
        </div>
    </section>
</body>
</html>

 

 

만드는 방법 풀이

 

body

<body>
    <section class="slider__wrap nexon">
        <h2 class="blind">메인 슬라이드 영역</h2>
        <div class="slider__inner">
            <div class="slider">
                <div class="slider__info container">
                    <span class="small">event</span>
                    <h1 class="title">냥집사들의 커뮤니티 Catt</h1>
                    <p class="desc">고양이 케어, 고양이 목욕,고양이 산책. 고양이 패션, 집사 커뮤니티
                        고양이와 관련된 모든 정보를 공유합니다.</p>
                    <div class="btn">
                        <a href="#">자세히 보기</a>
                        <a href="#">상담 신청</a>
                    </div>
                </div>
                <div class="slider__arrow">
                    <a href="#"><span class="blind">이전 이미지</span></a>
                    <a href="#"><span class="blind">다음 이미지</span></a>
                </div>
                <div class="slider__dot">
                    <a href="#" class="dot active"><span class="blind">첫번째 이미지</span></a>
                    <a href="#" class="dot"><span class="blind">두번째 이미지</span></a>
                    <a href="#" class="dot"><span class="blind">세번째 이미지</span></a>
                    <a href="#" class="play"><span class="blind">플레이</span></a>
                    <a href="#" class="stop"><span class="blind">정지</span></a>
                </div>
            </div>
        </div>
    </section>
</body>

전체적인 섹션 영역을 잡아줍니다. 

그리고 그 안에 컨테이너를 만들고 제목, event, 설명, 버튼을 넣어줍니다.

그 아래에 슬라이드 할 때 옆으로 넘기는 화살표를 만들어 줍니다.

화살표는 글자가 지워지면 영역이 인식이 안됩니다.

대신 글자가 보이면 안되기 때문에 class를 blind로 설정합니다.

아래 부분에 들어가는 아이콘들도 마친가지이므로 blind를 설정해줍니다.

 

style

.blind {
            position:absolute;
            clip:rect(0 0 0 0);
            width:1px;
            height:1px;
            margin:-1px;
            overflow:hidden
        }

blind부분을 설명하도록 하겠습니다.

position: absolute로 요소를 절대 위치로 배치합니다

clip: rect(0 0 0 0);: 요소의 모든 부분을 숨깁니다.

overflow: hidden;:으로요소 내용의 넘침을 숨깁니다

그 외 style 부분의 reset 부분과 common 부분은 이전 글들에서도 나왔으므로 설명을 생략하도록 하겠습니다.

/* sild__wrap */

        .slider__inner .slider {
            height: 600px;
            background-image: url(../assets/image/slideType_01_01.jpg);
            background-size: cover;
            background-repeat: no-repeat;
            background-position: center;
            position: relative;
            z-index: 1;
        }
        .slider__inner .slider::after {
            content: '';
            width: 100%;
            height: 100%;
            background-color:  rgba(224, 217, 88, 0.1);
            position: absolute;
            left: 0;
            top: 0;
            z-index: -1;
        }
        .slider__info {
            padding: 100px 0;
        }
        .slider__info .small {
            display: inline-block;
            padding: 1px 30px;
            background-color: #fff;
            color: #000;
            font-size: 16px;
            border-radius: 50px;
            text-transform: uppercase;
            margin-bottom: 10px;
        }
        .slider__info .title {
            font-size: 80px;
            color: #fff;
            margin-bottom: 40px;
            margin-left: -5px;
        }
        .slider__info .desc {
            font-size: 18px;
            line-height: 1.5;
            color: #fff;
            width: 50%;
            word-break: keep-all;
        }
        .slider__info .btn {
            margin-top: 100px;
        }
        .slider__info .btn a {
            width: 180px;
            background: #fff;
            font-size: 16px;
            display: inline-block;
            text-align: center;
            padding: 12px 0;
            margin-right: 4px;
        }
        .slider__info .btn a:last-child {
            background-color: #000;
            color: #fff;
        }
        .slider__arrow a {
            position: absolute;
            top: 50%;
            background-image: url(../assets/image/icon_main.svg);
            background-size: 500px;
            width: 30px;
            height: 56px;
            display: block;
            margin-top: -28px;
        }
        .slider__arrow a:first-child {   
            left: 20px;
        }
        .slider__arrow a:last-child {
            right: 20px;
            background-position: -52px 0;
        }
        .slider__dot {
            position: absolute;
            left: 50%;
            bottom: 20px;
            transform: translateX(-50%);
        }
        .slider__dot a {
           width: 16px;
           height: 16px;
           display: inline-block;
           background-image: url(../assets/image/icon_main.svg);
           background-size: 500px;
           margin: 0 3px;   
        }
        .slider__dot a.dot {
            background-position: -101px -1px;
        }
        .slider__dot a.active {
            background-position: -121px -1px;
        }
        .slider__dot a.play {
            background-position: -141px -1px;
        }
        .slider__dot a.stop {
            background-position: -161px -1px;
        }

 

화살표나 아래 들어갈 아이콘 부분들은 만들어서 svg로 저장한 후 각각의 요소에 넣어줍니다.

그리고 각 요소의 크기와 위치를 정해줍니다.

이미지 최적화

   @media only screen and (-webkit-min-device-pixel-ratio: 2),
            only screen and (min-device-pixel-ratio: 2),
            only screen and (min-resolution: 2dppx) {
                .slider__inner .slider {
                    background-image: url(../assets/image/slideType_01_01@2x.jpg);
                }   
            }

슬라이더 이미지를 최적화 시켜주어야 메모리도 줄어들고 화질도 유지되기 때문에 최적화 하는 것은 중요합니다,

아래 사이트에서 이미지 최적화를 시킨 후 media에 최적화한 이미지를 넣어주었습니다.

 

이미지 최적화 : https://imagecompressor.com/ko/

 

온라인 이미지 최적화기

Optimizilla는 궁극의 이미지 최적화기로 당신의 JPEG, GIF과 PNG 포맷을 가능한 최소 크기로 압축합니다.

imagecompressor.com

이렇게 하면 위의 예시와 같은 사이트가 만들어집니다!