문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
wiki:css:css_note:responsive_web_design_-_images [2021/06/29 08:02] emblim98 만듦 |
wiki:css:css_note:responsive_web_design_-_images [2023/01/13 18:44] (현재) |
||
|---|---|---|---|
| 줄 10: | 줄 10: | ||
| =====The source of this article===== | =====The source of this article===== | ||
| [[https:// | [[https:// | ||
| + | |||
| + | |||
| + | =====Using The width Property===== | ||
| + | width 속성이 백분율로 설정되고 height 속성이 " | ||
| + | |||
| + | <code css> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta http-equiv=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | img { | ||
| + | width: 100%; | ||
| + | height: auto; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | | ||
| + | <img src=" | ||
| + | < | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | 위의 예에서 이미지는 원래 크기보다 크게 확대될 수 있습니다.\\ | ||
| + | 대부분의 경우 더 나은 해결 방법은 대신 max-width 속성을 사용하는 것입니다.\\ | ||
| + | |||
| + | =====Using The max-width Property===== | ||
| + | '' | ||
| + | |||
| + | <code css> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta http-equiv=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | img { | ||
| + | max-width: 100%; | ||
| + | height: auto; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | | ||
| + | <img src=" | ||
| + | < | ||
| + | when the width is less than 460px.</ | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | =====Add an Image to The Example Web Page===== | ||
| + | <code css> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta http-equiv=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | * { | ||
| + | box-sizing: border-box; | ||
| + | } | ||
| + | |||
| + | img { | ||
| + | width: 100%; | ||
| + | height: auto; | ||
| + | } | ||
| + | |||
| + | .row::after { | ||
| + | content:""; | ||
| + | clear: both; | ||
| + | display: table; | ||
| + | } | ||
| + | |||
| + | [class*=" | ||
| + | float: left; | ||
| + | padding: 15px; | ||
| + | width: 100%; | ||
| + | } | ||
| + | |||
| + | @media only screen and (min-width: 600px) { | ||
| + | .col-s-1 {width: 8.33%;} | ||
| + | .col-s-2 {width: 16.66%;} | ||
| + | .col-s-3 {width: 25%;} | ||
| + | .col-s-4 {width: 33.33%;} | ||
| + | .col-s-5 {width: 41.66%;} | ||
| + | .col-s-6 {width: 50%;} | ||
| + | .col-s-7 {width: 58.33%;} | ||
| + | .col-s-8 {width: 66.66%} | ||
| + | .col-s-9 {width: 75%;} | ||
| + | .col-s-10 {width: 83.33%;} | ||
| + | .col-s-11 {width: 91.66%;} | ||
| + | .col-s-12 {width: 100%;} | ||
| + | } | ||
| + | |||
| + | @media only screen and (min-width: 768px) { | ||
| + | .col-1 {width: 8.33%;} | ||
| + | .col-2 {width: 16.66%;} | ||
| + | .col-3 {width: 25%;} | ||
| + | .col-4 {width: 33.33%;} | ||
| + | .col-5 {width: 41.66%;} | ||
| + | .col-6 {width: 50%;} | ||
| + | .col-7 {width: 58.33%;} | ||
| + | .col-8 {width: 66.66%} | ||
| + | .col-9 {width: 75%;} | ||
| + | .col-10 {width: 83.33%;} | ||
| + | .col-11 {width: 91.66%;} | ||
| + | .col-12 {width: 100%;} | ||
| + | } | ||
| + | |||
| + | html { | ||
| + | font-family: | ||
| + | } | ||
| + | |||
| + | .header { | ||
| + | background-color: | ||
| + | color:# | ||
| + | padding: 15px; | ||
| + | } | ||
| + | |||
| + | .menu ul { | ||
| + | list-style-type: | ||
| + | margin: 0; | ||
| + | padding: 0; | ||
| + | } | ||
| + | |||
| + | .menu li { | ||
| + | padding: 8px; | ||
| + | margin-bottom: | ||
| + | background-color: | ||
| + | color: #ffffff; | ||
| + | box-shadow: 1px 3px rgba(0, 0, 0, 0.12) 0 1px 2px rgba(0, 0, 0, 0.24); | ||
| + | } | ||
| + | |||
| + | .menu li:hover { | ||
| + | background-color: | ||
| + | } | ||
| + | |||
| + | .aside { | ||
| + | background-color: | ||
| + | padding: 15px; | ||
| + | color: #ffffff; | ||
| + | text-align: center; | ||
| + | font-size: 14px; | ||
| + | box-shadow: 1px 3px rgba(0, 0, 0, 0.12) 0 1px 2px rgba(0, 0, 0, 0.24); | ||
| + | } | ||
| + | |||
| + | .footer { | ||
| + | background-color: | ||
| + | color: #ffffff; | ||
| + | text-align: center; | ||
| + | font-size: 12px; | ||
| + | padding: 15px; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | <div class=" | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | <ul> | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ul> | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | The city can be divided in two parts, the old townand the modern city.</ | ||
| + | <img src="/ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | <div class=" | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <div class=" | ||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | =====Background Images===== | ||
| + | 배경 이미지는 크기 조정(resizing) 및 크기 조정(scaling)에도 반응할 수 있습니다.\\ | ||
| + | \\ | ||
| + | 여기에서는 세 가지 방법을 보겠습니다.\\ | ||
| + | \\ | ||
| + | 1. '' | ||
| + | 배경 이미지의 크기가 조절되고 콘텐츠 영역에 맞게 조정됩니다.\\ | ||
| + | 그러나 이미지는 자체의 종횡비(aspect ratio: 이미지의 너비와 높이 사이의 비례 관계)를 유지합니다.\\ | ||
| + | |||
| + | <code css> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta http-equiv=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | div { | ||
| + | border: 2px solid darkblue; | ||
| + | width: 100%; | ||
| + | height: 400px; | ||
| + | background-image: | ||
| + | background-repeat: | ||
| + | background-size: | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | | ||
| + | < | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | 2. '' | ||
| + | 배경 이미지가 전체 콘텐츠 영역을 덮도록 늘어납니다.\\ | ||
| + | |||
| + | <code css> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta http-equiv=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | div { | ||
| + | width: 100%; | ||
| + | height: 400px; | ||
| + | background-image: | ||
| + | background-size: | ||
| + | border: 2px solid darkblue; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | | ||
| + | < | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | 3. '' | ||
| + | 배경 이미지가 전체 콘텐츠 영역을 덮도록 크기가 조정됩니다.\\ | ||
| + | " | ||
| + | |||
| + | <code css> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta http-equiv=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | div { | ||
| + | width: 100%; | ||
| + | height: 400px; | ||
| + | background-image: | ||
| + | background-size: | ||
| + | border: 2px solid darkblue; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | | ||
| + | < | ||
| + | |||
| + | < | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | =====DifferentImages for Different Devices===== | ||
| + | 큰 이미지는 큰 컴퓨터 화면에서는 완벽할 수 있지만, 작은 장치에서는 쓸모가 없습니다.\\ | ||
| + | 어쨌든 축소해야 할 때 왜 큰 이미지를 로드합니까? | ||
| + | 부하를 줄이거나 다른 이유로, 미디어 쿼리를 사용하여 다양한 장치들에서 다른 이미지들로 표시할 수 있습니다.\\ | ||
| + | \\ | ||
| + | 다음은 다양한 장치들에서 표시될 하나의 큰 이미지와 하나의 더 작은 이미지입니다.\\ | ||
| + | |||
| + | <code css> | ||
| + | < | ||
| + | <html lang=" | ||
| + | < | ||
| + | <meta charset=" | ||
| + | <meta http-equiv=" | ||
| + | <meta name=" | ||
| + | < | ||
| + | < | ||
| + | /* For width smaller than 400px: */ | ||
| + | /* 너비 399px이하로 표시되는 이미지 */ | ||
| + | body { | ||
| + | background-repeat: | ||
| + | background-image: | ||
| + | } | ||
| + | |||
| + | /* For width 400px and larger: */ | ||
| + | /* 400px 너비까지 표시되는 이미지 */ | ||
| + | @media only screen and (min-width: | ||
| + | body { | ||
| + | background-image: | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | | ||
| + | <p style=" | ||
| + | | ||
| + | </p> | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | 브라우저 너비 대신 장치의 너비를 확인하는 '' | ||
| + | 미디어 쿼리 '' | ||
| + | 그러면 브라우저 창 크기를 조정할 때 이미지가 변경되지 않습니다.\\ | ||
| + | \\ | ||
| + | <code css> | ||
| + | < | ||
| + | /* For width smaller than 400px: */ | ||
| + | /* 너비 399px이하로 표시되는 이미지 */ | ||
| + | body { | ||
| + | background-repeat: | ||
| + | background-image: | ||
| + | } | ||
| + | |||
| + | /* For width 400px and larger: */ | ||
| + | /* 400px 너비까지 표시되는 이미지 */ | ||
| + | @media only screen and (min-device-width: | ||
| + | body { | ||
| + | background-image: | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | =====The HTML < | ||
| + | %%HTML%% '' | ||
| + | \\ | ||
| + | '' | ||
| + | 뷰포트 너비에 따라 확대 또는 축소되는 하나의 이미지를 사용하는 대신, | ||
| + | 브라우저 뷰포트를 더 멋지게 채우도록 여러 이미지를 디자인할 수 있습니다.\\ | ||
| + | \\ | ||
| + | '' | ||
| + | 다른 소스를 설정하고, | ||
| + | |||
| + | <code html> | ||
| + | < | ||
| + | | ||
| + | < | ||
| + | <source srcset=" | ||
| + | <source srcset=" | ||
| + | <img src=" | ||
| + | |||
| + | <p> | ||
| + | Resize the browser width and the background image will change at 400px | ||
| + | </p> | ||
| + | </ | ||
| + | | ||
| + | </ | ||
| + | </ | ||
| + | \\ | ||
| + | '' | ||
| + | \\ | ||
| + | '' | ||
| + | \\ | ||
| + | 또한 '' | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | |||