카테고리 없음

css에서 백그라운드 이미지 넣기와 반복시 반복막기

life... 2022. 4. 17. 00:10

 

.jumbotron-item-main-image {

  width: 50%;

 

 

  height: 100%;

  background-image: url("../img/igen.png");

}

이렇게만 넣으면 공간이 남아서 반복됨.

no-repeat 넣어서 반복막음.

 

 

.jumbotron-item-main-image {

  width: 50%;

 

 

  height: 100%;

  background-image: url("../img/igen.png");

  background-repeat: no-repeat;

}

 

 

원본사진과 다르게 잘리므로

  background-size: contain;

넣어준다.

 

.jumbotron-item-main-image {

  width: 50%;

  height: 100%;

  background-image: url("../img/igen.png");

  background-repeat: no-repeat;

  background-position: center;

  background-size: contain;

}

 

다르게 축약해서 아래처럼 나타낼 있다.

 

  background: url("../img/igen.png") no-repeat center / contain;

  /* position과 사이즈 사이에 /를 넣어서 구분지어야한다. */