background image original size code example

Example 1: background image size css

#example1 {
  background: url(mountain.jpg);
  background-repeat: no-repeat;
  background-size: auto;
}

#example2 {
  background: url(mountain.jpg);
  background-repeat: no-repeat;
  background-size: 300px 100px;
}

Example 2: css background full width

body { 
  background: url(img/bg-image.jpg) no-repeat center center fixed; 
  -webkit-background-size: cover;
  -moz-background-size: cover;
  -o-background-size: cover;
  background-size: cover;
}

Example 3: make backgrond image smaller

/*The cover value specifies that the background image should be sized
so that it is as small as possible while ensuring that both dimensions
are greater than or equal to the corresponding size of the container.*/

background-size: cover;

Tags:

Html Example