사이트 만들기

사이트 만들기 (슬라이드 유형) !

Kim do hyun 2023. 3. 15. 17:34
728x90
반응형

사이트 만들기 슬라이드 유형편

보더콜리를 주제로 한 사이트 슬라이드 부분입니다.
기준선과 레이아웃 그리드는 카드, 이미지 유형과 동일합니다.

 

피그마 디자인

 

 

아래는 코드로 만든 과정입니다.

 

 

HTML

<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">Loyal</span>
                    <h3 class="title">충성심</h3>
                    <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 class="slider"></div>
            <div class="slider"></div> -->
        </div>
    </section>
</body>

 

CSS

<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: #727272;
        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;
    }
    /* slider__wrap */
    .slider__inner .slider {
        height: 600px;
        background-image: url(../asset/img/slider-TYPE01@2x-min.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(0, 0, 0, 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: #500000;
        color: #fff;
        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;
        /* height: 40px;
        line-height: 40px; 야매 방법 */
        background-color: #fff;
        font-size: 16px;
        display: inline-block;
        text-align: center;
        padding: 12px 0;
        margin-right: 4px;
    }
    .slider__info .btn a:last-child {
        background-color: #500000;
        color: #fff;
    }
    .slider__arrow a {
        position: absolute;
        top: 50%;
        background-image: url(../asset/img/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: translate(-50%);
    }
    .slider__dot a {
        width: 16px;
        height: 16px;
        background-image: url(../asset/img/icon_main.svg);
        background-size: 500px;
        display: inline-block;
        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(../asset/img/slider-TYPE01@2x-min.jpg);
            }
        }
    </style>

css 코드 설명

  • background-position: 배경 이미지의 위치를 지정하는 속성입니다. x축 y축의 값을 이용해 배경 이미지를 원하는 위치로 이동시킬 수 있습니다.
  • background-image: 요소에 배경 이미지를 삽입하는 속성입니다. url() 함수 안에 이미지 파일의 경로를 입력해야 합니다.
  • background-size: 배경 이미지의 크기를 지정하는 속성입니다. contain, cover, auto, 100% 등의 값으로 지정할 수 있습니다.
  • background-repeat: 배경 이미지의 반복 여부를 지정하는 속성입니다. repeat, no-repeat, repeat-x, repeat-y 등의 값으로 지정할 수 있습니다.
  • transform: 요소의 모양을 변형시키는 속성입니다. translate(), scale(), rotate(), skew() 등의 함수를 사용해 요소를 이동, 확대, 회전, 비틀기 등의 효과를 줄 수 있습니다.
  • word-break: 단어가 줄바꿈되는 위치를 지정하는 속성입니다. normal, break-all, keep-all, break-word 등의 값으로 지정할 수 있습니다.
  • line-height: 텍스트 줄 간격을 지정하는 속성입니다. %, em, px, rem 등의 단위로 지정할 수 있습니다.
  • text-transform: 텍스트를 변환하는 속성입니다. uppercase, lowercase, capitalize 등의 값으로 지정할 수 있습니다.
  • z-index: 요소의 쌓이는 순서를 지정하는 속성입니다. auto, 0, 1, 2 등의 값으로 지정할 수 있습니다.
  • .slider__inner .slider::after {}: CSS 선택자의 일부로, .slider__inner 클래스 안에 있는 .slider 클래스의 가상 요소(::after)를 지정합니다.
  • content: '';: 가상 요소(pseudo element)에서 요소 내용(content)을 지정하는 속성입니다. before, after와 같은 가상 클래스와 함께 사용합니다.
  • overflow: 요소의 내용이 넘칠 때 처리 방법을 지정하는 속성입니다. visible, hidden, scroll, auto 등의 값으로 지정할 수 있습니다.
  • clip: 요소의 표시 영역을 지정하는 속성입니다. rect(top, right, bottom, left) 함수를 사용해 요소의 좌표와 너비, 높이를 지정합니다.
  • vertical-align: 인라인 요소의 수직 정렬 방법을 지정하는 속성입니다. baseline, top, middle, bottom 등의 값으로 지정할 수 있습니다.