๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Site ์ œ์ž‘

02. ์นด๋“œ ์œ ํ˜•-2

by Youcodein 2022. 8. 10.
728x90
๋ฐ˜์‘ํ˜•

์นด๋“œ์œ ํ˜•2

์นด๋“œ ์œ ํ˜• ๋ ˆ์ด์•„์›ƒ ์‚ฌ์ดํŠธ์ž…๋‹ˆ๋‹ค. html๊ณผ css๋กœ ์ž‘์—…ํ•˜์˜€์Šต๋‹ˆ๋‹ค.

๋ ˆ์ด์•„์›ƒ ์„ค์ •

figma๋กœ ๊ทธ๋ฆฌ๋“œ์™€ ์‚ฌ์ดํŠธ์˜ ๋ ˆ์ด์•„์›ƒ์„ ์žก์Šต๋‹ˆ๋‹ค.

HTML

html ์†Œ์Šค์ž…๋‹ˆ๋‹ค.

<body>
    <section id="cardType02" class="card__wrap gmark section gray">
        <h2>๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋ฅผ ๋ณด์„ธ์š”๐Ÿฆœ</h2>
        <p>
            ํ™”๋ คํ•œ ์•ต๋ฌด์ƒˆ์˜ ๊ด‘๊ธฐ, ํญ๋ ฅ์„ฑ, ๊ทธ๋ฆฌ๊ณ  ๊ท€์—ฌ์›€์„ ์•Œ๋ฆฌ๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.<br>
            ์‚ฌ๋žŒ๋“ค์ด ๋ญ๋ผ๊ณ  ํ•  ๋•Œ๋„ ์žˆ์ง€๋งŒ ๊ทธ๋Ÿฐ ๋ถ€๋ถ„๊นŒ์ง€  ์ •๋ง ๊ท€์—ฌ์šด๊ฑธ์š” ์˜ˆ์œ ์šฐ๋ฆฌ ์•ต๋ฌด์ƒˆ๋“ค์˜ ๋งค๋ ฅ์— ๋น ์ ธ๋ณด์„ธ์š”.
        </p>
        <div class="card__inner container">
            <article class="card">
                <img src="img/card_bg02_01.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">์ฒญ๊ธˆ๊ฐ•์ฒญ๊ธˆ๊ฐ•์ฒญ๊ธˆ๊ฐ•์ฒญ๊ธˆ๊ฐ•์ฒญ๊ธˆ๊ฐ•</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
            <article class="card">
                <img src="img/card_bg02_02.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">๋ชฉ๋„๋ฆฌ์•ต๋ฌด</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
            <article class="card">
                <img src="img/card_bg02_03.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">์™•๊ด€์•ต๋ฌด</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
            <article class="card">
                <img src="img/card_bg02_04.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">๋ชจ๋ž€์•ต๋ฌด</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
            <article class="card">
                <img src="img/card_bg02_05.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">์™•๊ด€์•ต๋ฌด</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
            <article class="card">
                <img src="img/card_bg02_06.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">์ฝ”๋‰ด์–ด</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
            <article class="card">
                <img src="img/card_bg02_07.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">์ฝ”์นดํˆฌ</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
            <article class="card">
                <img src="img/card_bg02_08.jpg" alt="์•ต๋ฌด์ƒˆ">
                <h3 class="tit">ํšŒ์ƒ‰์•ต๋ฌด</h3>
                <p class="desc">๋ฉ‹์ง„ ์•ต๋ฌด์ƒˆ๋“ค ์ƒํ™œ์„ ๋ณด์„ธ์š”. ์ฒญ๊ธˆ๊ฐ•์€ ์‚ฌ๋žŒ๋“ค์ด ์•Œ๊ณ  ์žˆ๋Š” ๋Œ€ํ‘œ์ ์ธ ์•ต๋ฌด์ƒˆ์ž…๋‹ˆ๋‹ค.
                ํ™”๋ คํ•œ ๊ทธ ๋ชจ์Šต์„ ๋ณด๋ฉด ๋ชจ๋‘ ์•ต๋ฌด์™€ ์‚ฌ๋ž‘์— ๋น ์ง€๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค.</p>
                <a href="#" class="more"><span class="iR">๋”๋ณด๊ธฐ</span></a>
            </article>
        </div>
    </section>
    
</body>

CSS

css ์†Œ์Šค์ž…๋‹ˆ๋‹ค. figma๋กœ ์„ค์ •ํ•ด๋†“์€ ๋ ˆ์ด์•„์›ƒ์ด๋‚˜ zaplin์„ ๋ณด๋ฉฐ ์ ์ ˆํ•˜๊ฒŒ css๋ฅผ ์„ค์ •ํ•ด์ค๋‹ˆ๋‹ค.

/* fonts */
@import url('https://webfontworld.github.io/gmarket/GmarketSans.css');

.gmark {
    font-family: GmarketSans;
    font-weight: 500;
}
 /* reset */
 * {
    margin: 0;
    padding: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: normal;
}

a {
    text-decoration: none;
    color: #000;
}

img {
    width: 100%;
}

/* common */
.container {
    width: 1160px;
    padding: 0 20px;
    margin: 0 auto;
    min-width: 1160px;
}

.section {
    padding: 120px 0;
}

.section>h2 {
    font-size: 50px;
    line-height: 1;
    text-align: center;
    margin-bottom: 20px;
}

.section>p {
    font-size: 22px;
    font-weight: 300;
    color: #666;
    text-align: center;
    margin-bottom: 70px;
}

.gray {
    background-color: #f5f5f5;
}
/* iR ํšจ๊ณผ(์ด๋ฏธ์ง€ ๋Œ€์ฒด ํšจ๊ณผ == alt) 
    ์ด๋ฏธ์ง€ ๋Œ€์ฒด ํ…์ŠคํŠธ ์ œ๊ณต์„ ์œ„ํ•œ css ๊ธฐ๋ฒ•. ์›น ์ ‘๊ทผ์„ฑ์„ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.*/
.iR {
    display: block;
    overflow: hidden;
    font-size: 0;
    line-height: 0;
    text-indent: -9999px;
}

/* cardType02 */

.card__inner{
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

.card__inner .card {
    width: 24%;
    position: relative;

}

.card__inner .card:first-child {
    margin-bottom: 50px;
}
.card__inner .card img {
    margin-bottom: 20px;
    border-radius: 10px;
}

.card__inner .card .tit {
    font-size: 28px;
    margin-bottom: 10px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding-right: 20px;
}
.card__inner .card .desc {
    font-size: 18px;
    font-weight: 300;
    color: #666;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3; 
    -webkit-box-orient: vertical;
}
.card__inner .card .more {
    width: 24px;
    height: 24px;
    background-image: url(img/arrow.svg);
    display: block;
    position: absolute;
    right: 0;
    top: 230px;
    border-radius: 5px;
}

โ€ปiR ํšจ๊ณผโ€ป

iR ํšจ๊ณผ(์ด๋ฏธ์ง€ ๋Œ€์ฒด ํšจ๊ณผ == alt)
์ด๋ฏธ์ง€ ๋Œ€์ฒด ํ…์ŠคํŠธ ์ œ๊ณต์„ ์œ„ํ•œ css ๊ธฐ๋ฒ•. ์›น ์ ‘๊ทผ์„ฑ์„ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค.

โ€ป๋ง์ค„์ž„ ํšจ๊ณผโ€ป

- ๋ง์ค„์ž„ ํšจ๊ณผ๋Š” ํ•œ ์ค„์˜ ์˜์—ญ ์•ˆ์— ๋ชจ๋“  ๊ธ€์ž๋ฅผ ๋„ฃ๊ณ  ์‹ถ์„ ๋•Œ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.
- ์˜์—ญ์„ ๋„˜์–ด๊ฐ€๊ฒŒ ๋˜๋ฉด ... ์œผ๋กœ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.
- ๋ง์ค„์ž„ ํšจ๊ณผ๋ฅผ ์ ์šฉํ•˜๊ณ  ์‹ถ์€ ์˜์—ญ์— ์•„๋ž˜ ํƒœ๊ทธ๋ฅผ ๋„ฃ์Šต๋‹ˆ๋‹ค.

ํ•œ ์ค„ ํšจ๊ณผ

{
width:100px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

๋‘ ์ค„ ํšจ๊ณผ

{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}

์„ธ ์ค„ ํšจ๊ณผ

{
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 3;
-webkit-box-orient: vertical;
}

728x90
๋ฐ˜์‘ํ˜•

'Site ์ œ์ž‘' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

02. ์ด๋ฏธ์ง€ ์œ ํ˜• - 3  (4) 2022.08.21
02. ์ด๋ฏธ์ง€ ์œ ํ˜• - 2  (3) 2022.08.18
02. ์ด๋ฏธ์ง€ ์œ ํ˜• - 1  (3) 2022.08.18
03. ์นด๋“œ ์œ ํ˜• - 3  (11) 2022.08.11
01. ์นด๋“œ ์œ ํ˜•-1  (3) 2022.08.09

๋Œ“๊ธ€