0

I need to resize my background "Image.png" to be 112 x 22 pixels, but when I modify width and height, it crops the image to the size provided instead of resizing it.
How can I resize the image in CSS?

#Title-1 {
  width: 148px;
  height: 29px;
  margin-left: 10px;
  background-image: url("/pic/Image.png");
  display: inline-block;
  vertical-align: top;
}
Leon Adler
  • 2,993
  • 1
  • 29
  • 42
  • since you are using the image as a **CSS background**, not as an inline image (``), take a look at [this reference answer](http://stackoverflow.com/questions/376253/stretch-and-scale-css-background) and the CSS property `background-size`. – Leon Adler Jan 20 '16 at 18:54
  • Possible duplicate of [Resize image proportionally with CSS?](http://stackoverflow.com/questions/787839/resize-image-proportionally-with-css) – Roy Falk Jan 20 '16 at 19:08

3 Answers3

0

Have you tried the background-size option?

background-size: 112px 22px;
0

It is because when you modify the width and height values, you are actually changing those values for the container.

You'll want to add this to your CSS:

#Title-1 {
    background-size: 112px 22px;
    background-repeat: no-repeat;
}
0

I get it now,

And I solved it by using:

background-size:cover

Thank you all.