9. 배경이미지

 

background-repeat

이미지 반복시키는 여부 정하는 속성

/* 반복하지 않음 */
background-repeat: no-repeat;

/* 가로 방향으로만 반복 */
background-repeat: repeat-x;

/* 세로 방향으로만 반복 */
background-repeat: repeat-y;

/* 가로와 세로 모두 반복 */
background-repeat: repeat;

/* 반복할 수 있는 만큼 반복한 뒤, 남는 공간은 이미지 간의 여백으로 배분 */
background-repeat: space;

/* 반복할 수 있는 만큼 반복한 뒤, 남는 공간은 이미지 확대를 통해 배분 */
background-repeat: round;

 

background-size

배경 이미지의 사이즈를 정해주는 속성

/* 원래 이미지 사이즈대로 출력 */
background-size: auto;

/* 화면을 꽉 채우면서, 사진 비율을 유지 */
background-size: cover;

/* 가로, 세로 중 먼저 채워지는 쪽에 맞추어서 출력 */
background-size: contain;

/* 픽셀값 지정 (가로: 40px, 세로: 50px로 설정) */
background-size: 40px 50px;

/* 퍼센트값 지정 (가로: 부모 요소 width의 50%, 세로: 부모 요소 height의 70%로 설정) */
background-size: 50% 70%;

 

background-position

배경 이미지의 위치를 정해주는 속성

/* 단어로 지정해주기 (가로: left, center, right, 세로: top, center, bottom) */
/* 아래와 같은 총 9개의 조합이 가능 */
background-position: left top;
background-position: left center;
background-position: left bottom;
background-position: right top;
background-position: right center;
background-position: right bottom;
background-position: center top;
background-position: center center;
background-position: center bottom;

/* 퍼센트로 지정해주기 (가로: 전체 width의 25% 지점, 세로: 전체 height의 75% 지점 ) */
background-position: 25% 75%;

/* 픽셀로 지정하기 (가로: 가장 왼쪽 가장자리에서부터 오른쪽으로 100px 이동한 지점, 세로: 가장 상단 가장자리에서 아래로 200px 이동한 지점) */
background-position: 100px 200px;

 

 

 

 

 

 


https://www.instagram.com/p/CbXiU3xvGl2/?utm_source=ig_web_copy_link

부족하거나 잘못된 내용이 있을 경우 댓글 달아주시면 감사하겠습니다.

이 글에 부족한 부분이 존재할 경우 추후에 수정될 수 있습니다.


 

'CS > HTML CSS' 카테고리의 다른 글

8. box-sizing  (0) 2022.05.07
7. border-radius, background-color, box-shadow  (0) 2022.05.07
6. width, height, overflow  (0) 2022.05.07
5. border  (0) 2022.05.07
4. Margin, Padding  (0) 2022.05.07