๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ”ฅ TIL

์ด๋ฏธ์ง€ ์นด๋“œ ๋ฆฌ์ŠคํŠธ ๋งŒ๋“ค๊ธฐ(image card list) +์ถ”๊ฐ€์ˆ˜์ •

๋ฐ˜์‘ํ˜•

์ฐธ๊ณ  ํ™ˆํŽ˜์ด์ง€

https://www.yuseong.go.kr/prog/trrsrt/TRSE_01/tour/sub02_01/list.do

๊ธฐ๊ฐ„

21.10.13 ~ 21.10.14

๐Ÿ”ฅ ์ฃผ์˜์‚ฌํ•ญ ๐Ÿ”ฅ

๋ถˆํ•„์š”ํ•œ ํƒœ๊ทธ ๋นผ๊ธฐ.

์•Œ๋งž์€ ํƒœ๊ทธ ๋„ฃ๊ธฐ.

๋””์ž์ธ์— ๋งž๊ฒŒ ์ ์šฉํ•˜๊ธฐ.

 

๐Ÿ“Œ [์ •๋ฆฌ]

  1. ํ…์ŠคํŠธ๋ถ€ํ„ฐ ์ฑ„์šด๋‹ค. font์—์„œ ๋ถ€ํ„ฐ padding,margin์„ ๋์œผ๋กœ ์•ˆ์—์„œ ๋ฐ–์œผ๋กœ ์ž‘์—…ํ•œ๋‹ค.
  2. img์˜ ๊ฒฝ๋กœ๊ฐ€ ์ž˜๋ชป๋˜๊ฑฐ๋‚˜ ๋กœ๋”ฉ์ด ์•ˆ ๋  ๊ฒฝ์šฐ, ๋Œ€์ฒด ์ด๋ฏธ์ง€๋ฅผ ๋„ฃ์–ด์ค€๋‹ค.
    1. img src="" onerror="this.src='๋Œ€์ฒด์ด๋ฏธ์ง€๊ฒฝ๋กœ'"
    2. background-image
  3. ํ…์ŠคํŠธ๋Š” ๋ง์ค„์ž„ํ‘œ๋ฅผ ๋„ฃ์–ด์ค€๋‹ค.
  4. ์ด๋ฏธ์ง€ ๋†’์ด๋Š” padding-top์œผ๋กœ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ๊ทธ ์•ˆ์„ ์ด๋ฏธ์ง€๋กœ ์ฑ„์šด๋‹ค.
.img {
position: relative;
padding-top: 245px;
}
.img .img-inner {
position: absolute;
top: 0; right: 0; bottom: 0; left: 0;
width: 100%; height: 100%;
}
.img .img-inner img {
/* ์ด๋ฏธ์ง€ ๊ฐ€์šด๋ฐ ์ •๋ ฌ */
position: absolute;
top: 50%; left: 50%;
transform: translate(-50%, -50%);
/* ์ด๋ฏธ์ง€ ๋†’์ด๋กœ ๊ธฐ์ค€ ๋งž์ถ”๊ธฐ */
height: 100%;
}
  1. IR :: ์ด๋ฏธ์ง€๋ฅผ ๋Œ€์ฒดํ•˜๋Š” ํ…์ŠคํŠธ (ํ™ˆํŽ˜์ด์ง€์—์„œ๋Š” ์•„๋ž˜์™€ ๊ฐ™์€ IR๊ธฐ๋ฒ• ์‚ฌ์šฉ.)
.ir {
overflow: hidden;
font-size: 0;
line-height: 0;
/* ๋Œ€์ฒด ์ด๋ฏธ์ง€ ๋„ฃ๊ธฐ */
background-image: url('');
}
  1. ์ ‘๊ทผ๊ฐ€๋Šฅํ•œ ์ˆจ๊น€ ํ…์ŠคํŠธ๋ฅผ ์ฐธ๊ณ ํ•˜์—ฌ blind ํด๋ž˜์Šค๋ฅผ ๋„ฃ์–ด ์ด๋ฏธ์ง€๋ฅผ ๋Œ€์ฒด.
<span class="info"><i class="blind">์ด๋ฏธ์ง€๋Œ€์ฒด</i></span>
.info {
background-image: url('');
}
.blind {
overflow: hidden;
display: inline-block;
position: relative;
z-index: -1;
border: 0;
width: 1px;
height: 1px;
clip: rect(1px, 1px, 1px, 1px);
clip-path: inset(50%);
}

 




(+) ์ถ”๊ฐ€์ˆ˜์ •์‚ฌํ•ญ 21.10.15

โœ”๏ธ ํผ๋ธ”๋ฆฌ์‹ฑํ•  ๋•Œ๋Š” ํ™•์žฅ์„ฑ, ๋‹จ์ˆœ์„ฑ์„ ํ•ญ์ƒ ์ƒ๊ฐํ•ด์•ผ ํ•œ๋‹ค.

  • ๋ณดํ†ต์€ ๋™์ผ ์˜์—ญ์œผ๋กœ ์ž‘์—…ํ•ด ์ด๋ฏธ์ง€๊ฐ€ ์—†๋Š” ๊ฒฝ์šฐ๋Š” ์—†๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ, ํ…์ŠคํŠธ๋งŒ ์žˆ์„ ์ˆ˜ ์—†๋‹ค.
  • ๋‘ ๋ฒˆ์งธ ๋ฆฌ์ŠคํŠธ์ฒ˜๋Ÿผ ๋Œ€์ฒด ์ด๋ฏธ์ง€๋ฅผ ๋„ฃ์–ด์ค€๋‹ค.
  • ์กฐํšŒ์ˆ˜, ์ง€์—ญ ๋ถ€๋ถ„์— ๋งŒ์•ฝ 2๊ฐœ ์ดํ•˜์ด๊ฑฐ๋‚˜ 3๊ฐœ ์ด์ƒ์ผ ๊ฒฝ์šฐ ์–ด๋–ป๊ฒŒ ํ• ๊ฑด์ง€.
  • <strong>"์œ ๋ฆผ๊ณต์›"</strong> ๋ถ€๋ถ„์„ h2์œผ๋กœ ์ˆ˜์ •.
  • html ํƒœ๊ทธ ์ถ•์†Œํ™” :: ์ด๋ฏธ์ง€ ๋ถ€๋ถ„์— ํƒœ๊ทธ ํ•˜๋‚˜ ๋” ์ค„์ผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™๋‹ค.
  • resize์‹œ ๋ฆฌ์ŠคํŠธ ์ค‘๊ตฌ๋‚œ๋ฐฉ์œผ๋กœ ๋–จ์–ด์ง. @media ํ•„์š”.

 

๐Ÿ˜ญ ๋ง‰ํ˜”๋˜ ๋ถ€๋ถ„ 1-1.

์›น ์ ‘๊ทผ์„ฑ์œผ๋กœ ์ด๋ฏธ์ง€์˜ ์„ค๋ช…์„ ๋„ฃ์–ด์ค˜์•ผ ํ•œ๋‹ค.

<!-- ๋ฌธ์ œ์  :: i์— ๋Œ€์ฒด์ด๋ฏธ์ง€๋ฅผ ๋ชป ๋„ฃ์Œ. -->
<div class="local">
    <span><i class="icon1"></i>541</span>
    <span><i class="icon2"></i>์˜จ์ฒœ1๋™</span>
</div>

<!-- ์•„๋ž˜๋กœ ๋ณ€๊ฒฝ -->
<div class="local">
    <span class="view"><i class="blind">์กฐํšŒ์ˆ˜</i>541</span>
    <span class="place"><i class="blind">์žฅ์†Œ</i>์˜จ์ฒœ1๋™</span>
</div>
.blind {
    position: absolute;
    clip: rect(0,0,0,0);
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
}

 

 

๐Ÿ˜ญ ๋ง‰ํ˜”๋˜ ๋ถ€๋ถ„ 1-2.

๋…ธ๋ž‘์ƒ‰๋ถ€๋ถ„์—์„œ ๋ง์ค„์ž„์ ์šฉ์„ ํ–ˆ๋Š”๋ฐ ๊ธ€์ด ๋„˜์ณ์„œ ๋‘ ์ค„๋กœ ๋‚˜ํƒ€๋‚ฌ๋‹ค.

.local span {
    overflow: hidden;
    text-overflow: ellipsis;
    /* inline-box :: inline-block์ฒ˜๋Ÿผ ํ•œ ์นธ์— ๋‘ ๋ฐ•์Šค ๋“ค์–ด๊ฐ€๊ธฐ ์œ„ํ•ด. */
	display: -webkit-inline-box;
    /* ๋ง์ค„์ž„ ํ•œ์ค„ ์ฒ˜๋ฆฌ */
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    font-size: 15px;
    color: #666;
}
break-all (x)

word-break: break-all์„ ํ•ด์ฃผ์–ด ํ…์ŠคํŠธ ํ•˜๋‚˜์”ฉ ๋‹ค ๊นจ์ค€๋‹ค.

๊ทธ๋Ÿฌ๋ฉด ํ•œ ์ค„๋กœ ์ž˜ ๋‚˜์˜ค๊ฒŒ ๋œ๋‹ค.

 

 

๐Ÿ˜ญ ๋ง‰ํ˜”๋˜ ๋ถ€๋ถ„ 1-3.

span.view, span.place ํด๋ž˜์Šค ๋ช…์„ ์ง€์ •ํ•ด์ค€ ์ด์œ .

/* 1 */
.main-tour .txt .local .span:nth-of-type(1)::before {}
.main-tour .txt .local .span:nth-of-type(2)::before {}

/* 2 */
.main-tour .txt .local .view::before {}
.main-tour .txt .local .place::before {}

1๋ฒˆ์œผ๋กœ ํ–ˆ์„ ๊ฒฝ์šฐ, ์ฒซ๋ฒˆ์งธ span์ด ์‚ฌ๋ผ์ง€๋ฉด ๋‘๋ฒˆ์งธ span์ด ์ฒซ๋ฒˆ์งธ ์ด๋ฏธ์ง€๋ฅผ ๊ฐ€์ง„๋‹ค. ๊ทธ๋Ÿฌ๋ฏ€๋กœ ๊ฐ๊ฐ์˜ ํ•ด๋‹น background-image๋ฅผ ๊ฐ€์ง€์ง€ ๋ชปํ•œ๋‹ค.

2๋ฒˆ ๋ฐฉ๋ฒ•์ฒ˜๋Ÿผ ํด๋ž˜์Šค๋ฅผ ์ง€์ •ํ•ด์ฃผ์–ด ์ˆœ์„œ๊ฐ€ ๋ฐ”๋€Œ์–ด๋„ ํด๋ž˜์Šค์˜ ๊ณ ์ •๋œ ์ด๋ฏธ์ง€์—ฌ์•ผ ํ•œ๋‹ค.

 

 

๐Ÿ˜ญ ๋ง‰ํ˜”๋˜ ๋ถ€๋ถ„ 1-4.

span์ด 1๊ฐœ์ผ ๋•Œ, 2๊ฐœ์ผ ๋•Œ, n๊ฐœ ์ผ ๋•Œ?

.local span:first-of-type:nth-last-of-type(1) {
    display: -webkit-box;
    max-width: 100%;
}
.local span:first-of-type:nth-last-of-type(2) {
    margin-left: 0px;
    max-width: 40%;
}
.local span:first-of-type:nth-last-of-type(2) ~ span {
    margin-left: 26px;
    max-width: 40%;
}
.local span:first-of-type:nth-last-of-type(3) {
    margin-left: 0;
    max-width: 30%;
}
.local span:first-of-type:nth-last-of-type(3) ~ span {
    margin-left: 10px;
    max-width: 30%;
}
.local span:nth-of-type(n+4) {
    display: none;
}

~ :: ๋ณธ์ธ์„ ๋บ€ ๋ชจ๋“  ํ˜•์ œ ๋…ธ๋“œ(ํ•˜๋‚˜์ด์ƒ.)

+ :: ๋ณธ์ธ์„ ๋บ€ ๋ฐ”๋กœ ๋‹ค์Œ ํ˜•์ œ ๋…ธ๋“œ(ํ•˜๋‚˜)

:fist-of-type:nth-last-of-type(n) :: ์ž์‹ .



๐Ÿ“‚img_card_list

๋ฐ˜์‘ํ˜•