I am trying to set the width of a background image — without modifying the height of said image. Is there a way to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Prior to CSS3
To have full control of the background image you could create a div with a really low
z-indexandposition:absolute; top:0; bottom: 0;to make everything float above it.If you don’t want to hard code the height of your image you’ll need to use javascript to do the stretching, otherwise it will just scale according to the ratio between width and height.
CSS3
In css3 you can use the property
background-size, but it’s the same thing here.. you’ll need to use javascript if you don’t want the image to scale according to the ratio between width and height.