[CSS] background와 background-color의 차이

daun·2022년 6월 13일
0

[오답노트]

목록 보기
14/26

background와 background-color의 차이

-background 는 여러개의 속성을 가질 수 있다.
-background-color는 색을 지정하는 단일 속성만 가질 수 있다.
따라서 background가 background-color를 포함한다.

버튼의 배경 속성을 초기하고 싶을 때

-background:none // 배경 속성을 없앤다.
-background:transparent // 배경 속성을 투명하게 한다.

두 속성의 차이는?

  • 사실 background는 아래의 속성을 한번에 쓰는 방법이다.
background-color
background-image
background-repeat
background-attachment
background-position
background-size
  • 이를 한줄로 쓰면 아래와 같음
background: color image repeat attachment position / size;
  • none이라는 값은 background-image에 들어가는 값이다.
    그러니까 background:none을 풀어서 쓰면
    background-image: none와 같다.
  • transparent는 background-color에 쓰이는 값이다.
    background: transparent을 풀어쓰면 아래와 같다.

결론

두 값을 풀어서 보면, background-color 속성이냐,
background-image 속성이냐 차이이지 기능상의 큰 차이는 없다!

profile
Hello world!

0개의 댓글