Daniela Buttigieg
Daniela Buttigieg

Reputation: 1

Resizing Background Images in CSS

I'm new to HTML. Can anyone please tell me how can I resize the background image in CSS?

Upvotes: 0

Views: 103

Answers (3)

Anto S
Anto S

Reputation: 2449

img{ width:100%;}

Add this into your css and use !important if necessary. this will work.

Upvotes: 0

hossein
hossein

Reputation: 119

Keywords syntax

background-size: cover;
background-size: contain;

One-value syntax
the width of the image (height set to 'auto')

background-size: 50%;
background-size: 3em;
background-size: 12px;
background-size: auto;

Two-value syntax
first value: width of the image, second value: height

background-size: 50% auto;
background-size: 3em 25%;
background-size: auto 6px;
background-size: auto auto;

Multiple backgrounds values by background-image
Do not confuse this with background-size: auto auto
background-size: auto, auto;
background-size: 50%, 25%, 25%;
background-size: 6px, auto, contain;

background-size: inherit;

more: https://developer.mozilla.org/en-US/docs/Web/CSS/background-size

Upvotes: 1

asamolion
asamolion

Reputation: 848

You can use the CSS background-size property.

http://www.w3schools.com/cssref/css3_pr_background-size.asp

I hope that answers the question.

Upvotes: 1

Related Questions