Currently, I create a 1288x200 image (https://jstock.org/images/banner.png).

I want it to shown as 100px height banner. The reason I'm using 2x height, as I want it to look good in retina display.

As you can see in current outcome, it doesn't look good - https://jstock.org/

enter image description here

I try to change from

.banner {
    height: 100px;
    background: #3B3E44 url('images/banner.png');
}

to

.banner {
    height: 100px;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-size: cover;
    background: #3B3E44 url('images/banner.png');
}

But, the outcome is still the same.

Can anyone provide me some hint, on how to scale down the background image proportionally?

1 Answers

2
Nisharg Shah On Best Solutions

you set your background-size to contain so it contain your image in your height

.banner {
    height: 100px;
    background: #3B3E44 url("https://jstock.org/images/banner.png");
    background-repeat: no-repeat;
    background-size: contain;
    background-position: center;
}
<div class="banner"></div>