Hazel Han
Midnight In Coding
Hazel Han
전체 방문자
오늘
어제
  • 분류 전체보기 (46)
    • Back-end (6)
      • java (0)
      • spring frameworks (6)
      • spring boot (0)
    • Front-end (29)
      • React (7)
      • Javascript (0)
      • html (7)
      • css (15)
    • DB (0)
    • Algorithms (2)
    • 회고록 (9)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • HTML
  • 코딩
  • React
  • Spring
  • 개발자
  • 남궁성
  • coding
  • 기술블로그
  • 리액트
  • justcode
  • 회고록
  • css
  • Java
  • 스프링
  • 자바
  • 프로그래밍
  • springframeworks
  • 스프링프레임워크
  • 저스트코드
  • 자바의정석

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
Hazel Han

Midnight In Coding

[css] 배경이미지
Front-end/css

[css] 배경이미지

2022. 9. 6. 11:43

배경에 이미지 채우는 방법

background-image: url("이미지 주소");

 

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;

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

/* 퍼센트값 지정 (가로: 부모 요소 width의 60%, 세로: 부모 요소 height의 70%로 설정) */
background-size: 60% 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;

 

저작자표시 (새창열림)

'Front-end > css' 카테고리의 다른 글

[css] 단위  (0) 2022.09.06
[css] 선택자 정리  (0) 2022.09.06
[css] box-sizing  (0) 2022.09.06
[css] box-shadow(그림자)  (0) 2022.09.05
[css] border  (0) 2022.09.05
    'Front-end/css' 카테고리의 다른 글
    • [css] 단위
    • [css] 선택자 정리
    • [css] box-sizing
    • [css] box-shadow(그림자)
    Hazel Han
    Hazel Han

    티스토리툴바