CSS

이미지텍스트 유형 페이지 만들기!

hyejeong3283 2023. 3. 14. 18:59
728x90
반응형

Figma

피그마를 이용해서 만들고자하는 이미지텍스트 유형 페이지를 작업했습니다.

 

HTML 코드

<!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>
</head>
<body>
    <section class="imgtext__wrap section nexon">
        <div class="container">
            <div class="imgtext__inner">
                <article class="imgtext">
                    <span class="section__small">notice</span>
                    <div class="imgtext__body">
                        <h2 class="section__h2">반려동물과 외출하기</h2>
                        <h3 class="title">반려동물 외출 시 챙겨야 할 것들과 주의사항입니다.</h3>
                        <ul class="desc">
                            <li>인식표 부착하기</li>
                            <li>목줄 등 안전조치하기</li>
                            <li>맹견의 경우 입마개 착용하기</li>
                            <li>배설물 수거하기</li>
                            <li>입장제한 여부 확인하기</li>
                            <li>반려동물을 안은 상태에서의 운전금지</li>
                            <li>대중교통 이용시 이동가방 사용하기</li>      
                        </ul>
                    </div>
                </article>
                <article class="imgtext">
                    <figure class="imgtext__header">
                        <img src="../asset/img/imgtextType01_01.jpg">
                    </figure>
                </article>
                <article class="imgtext">
                    <figure class="imgtext__header">
                        <img src="../asset/img/imgtextType01_02.jpg">
                    </figure>
                </article>
            </div>
        </div>
    </section>
</body>
</html>

body 안에 html 태그들을 사용하여 각 영역별 보여줄 정보들을 정의합니다.

영역마다 class명을 주어 보다 효과적으로 css를 적용시킬 수 있습니다.

 

body 안에 imgtext라는 클래스명을 가진 태그의 영역을 3개 만들어주었습니다.

1번째 영역에는 텍스트를, 2,3번째 영역에는 이미지를 넣었습니다.

 

CSS 코드

<link href="https://webfontworld.github.io/NexonLv1Gothic/NexonLv1Gothic.css" rel="stylesheet">
    <style>
        /* reset */
        * {
            margin: 0;
            padding: 0;
        }
        a {
            text-decoration: none;
        }
        h1,h2,h3,h4,h5,h6 {
            font-weight: normal;
        }
        img {
            vertical-align: top;
            width: 100%;
        }
        .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: #c95353;
            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;
        }

        /* imgtext__wrap */
        .imgtext__inner {
            display: flex;
            justify-content: space-between;
        }
        .imgtext__inner .imgtext {
            width: 32.3333%;
            background-color: #f8f8f8;
        }
        .imgtext__body .title{
            font-size: 22px;
            margin-bottom: 15px;
            color: #666;
        }
        .desc {
            font-size: 16px;
            color: #666;
            line-height: 1.5;
            margin-bottom: 15px; 
            padding-left: 18px;        
        }
        
    </style>

head 안에 사용할 폰트를 링크 태그를 통해 호출하여 사용합니다.

style을 영역을 선언 후, 그 안에 html 태그 및 class명에 따른 스타일(css)효과를 작성합니다.

 

CSS(reset)

  • * 를 사용해 전체화면에 margin 0과 padding 0 효과를 줍니다.
  • a 태그에는 텍스트 장식과 컬러 효과를 정의해줍니다.
  • h1~h6태그에는 폰트 굵기를 정의해줍니다.
  • img 태그에는 수직정렬, width, 컬러 값을 정의해줍니다.

공통CSS(common)

  • container class를 가진 태그에는 width, margin, padding 값을 공통적으로 부여합니다.
  • nexon class를 가진 태그에는 폰트와 폰트굵기를 부여합니다.
  • section class를 가진 태그에는 padding값을 부여합니다.
  • section과 center 두 class 동시에 가진 태그에는 text정렬 값을 부여합니다. (class="section center";)
  • card__inner의 자식요소 중 card class를 가진 태그에 width, bgc 값을 부여합니다.
  • card__body의 자식요소 중 btn class를 가진 태그에 padding-right, background-image, bg-repeat, bg-position 값을 부여합니다.

 

완성된 페이지