html - Responsive web design : "How to resize a background image according to browser window size using CSS"? -


i creating site products images re-size according browser window size i wrote media queries used 1 big image , re-sized in different window size but have 1 image used in background , how can re-size it? want support in browser in ie7 , 8.

html

<div></div> 

css

div{  background: url("http://canadianneighborpharmacy.net/images/cnp/discount_20.png")  no-repeat scroll 0 0 transparent; position:absolute; width:45px;  height: 45px; } 

my live code here :- http://jsfiddle.net/jamna/ddxbq/19/ here have main "product image" resizing according browser window size(in fiddle didn't write code resizing product image yet,i showing image want resize ) have "save-money label" image in background of "span" want re-size simultaneously product image.

for can use background-size property

like :

body{ background-size:cover; -moz-background-size:cover; -webkit-background-size:cover; } 

there other properties contain & 100% 100%

check link http://css-tricks.com/3458-perfect-full-page-background-image/

for ie can use filter

filter: progid:dximagetransform.microsoft.alphaimageloader(src='.mybackground.jpg', sizingmethod='scale'); -ms-filter: "progid:dximagetransform.microsoft.alphaimageloader(src='mybackground.jpg', sizingmethod='scale')"; 

edit: live code right have define width & height in percentage this

http://jsfiddle.net/sandeep/ayukz/3/

& can use img tag http://jsfiddle.net/sandeep/rmgnm/

img{ position:absolute; width:100%; height: 100%} 

edit:

may that's want http://jsfiddle.net/sandeep/ddxbq/20/

check link http://www.alistapart.com/d/responsive-web-design/ex/ex-site-flexible.html


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -