0

How can I stretch an image to use all the WIDTH of page?

I am using div tag.

<div align="center">
                <img class="s1" src="<%=image%>"/>
        </div>


img.s1
{
display: block;
margin-left: auto;
margin-right: auto;
border-width: 0px 0px 0px 0px;
size: 100%;
}

Thanks.

kitokid
  • 3,009
  • 17
  • 65
  • 101
  • This should answer your question: http://stackoverflow.com/questions/376253/stretch-and-scale-css-background –  Nov 03 '11 at 08:54

2 Answers2

2

You can specify that the image be the width of its container, if that is the page, then so be it - but you need to specify width, not size:

width: 100%;

Similarly, you can also specify the height; this might become useful in your case, as, if you check the test case provided by ShadowWizard then you'll notice, the aspect ratio may be kept (which could either shrink the height within its container or expand it out of the container). Using height will force it to size accordingly, obviously.

Grant Thomas
  • 44,454
  • 10
  • 85
  • 129
2
img.s1 {
  width: 100%;
}

or .. if you want absolute positioning

img.s1 {
  position: absolute;
  left: 0;
  right: 0;
}
Fred
  • 4,195
  • 2
  • 29
  • 42