Prevent an image from overflowing table size

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I have a table with an image in it that is larger that the width and height.

<table class="dataTable" width="500px" height="400px" border="0"
cellpadding="0" cellspacing="0">
<tr height="400px" >
<td nowrap style="width:500px">
<asp:Image id="CompanyPicture" ImageUrl="\uploads\SmartCorner1.jpg"
runat="server"/>
</td>
</tr>
</table>

If the picture is 600 by 500, it goes over the size of the table.

With text, this would force it to wrap.

Isn't the table dimensions supposed to constrain the image and text to that
maximum size?

Thanks,

Tom
 
width and height are hints. to force absolute sizes you need to use a
style command. also unless you specify an overflow behavior, the image
will still be bigger than the table. you could specify a size of the
image and the browser will scale it.

-- bruce (sqlwork.com)
 
bruce barker said:
width and height are hints. to force absolute sizes you need to use a
style command. also unless you specify an overflow behavior, the image
will still be bigger than the table. you could specify a size of the image
and the browser will scale it.

How do you do that?

I tried making the changes to styles and I am still getting the same
problem:

<anthem:Panel ID="GeoCodesDiv" Visible="true" style="position:absolute;
top:110px; left:500px; z-index:2000" runat="server">
<table class="dataTable" style="height:400px; width:500px" border="0"
cellpadding="0" cellspacing="0">
<tr style="height:400px">
<td nowrap style="width:500px">
<asp:Image id="CompanyPicture" ImageUrl="\uploads\SmartCorner1.jpg"
runat="server"/>
</td>
</tr>
</table>
</anthem:Panel>

Tom
 
<table class="dataTable" style="height:400px; width:500px" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="overflow:hidden;width:500px;height:400px">
<asp:Image id="CompanyPicture" ImageUrl="\uploads\SmartCorner1.jpg"
runat="server"/>
</div>
</td>
</tr>
</table>
 
Milosz Skalecki said:
<table class="dataTable" style="height:400px; width:500px" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="overflow:hidden;width:500px;height:400px">
<asp:Image id="CompanyPicture" ImageUrl="\uploads\SmartCorner1.jpg"
runat="server"/>
</div>
</td>
</tr>
</table>

That worked great.

Are there any other options I could do with this such that it would resize
if too large but wouldn't stretch it if smaller than the table size.

Thanks,

Tom
 
Howdy,

Yes, there are. See my replies to topic (it should work for regular
asp:image as well):

http://www.microsoft.com/communitie...pnet&mid=d7f63eeb-e86a-4257-8fce-f3c3e2f7a618
--
Milosz


tshad said:
Milosz Skalecki said:
<table class="dataTable" style="height:400px; width:500px" border="0"
cellpadding="0" cellspacing="0">
<tr>
<td>
<div style="overflow:hidden;width:500px;height:400px">
<asp:Image id="CompanyPicture" ImageUrl="\uploads\SmartCorner1.jpg"
runat="server"/>
</div>
</td>
</tr>
</table>

That worked great.

Are there any other options I could do with this such that it would resize
if too large but wouldn't stretch it if smaller than the table size.

Thanks,

Tom
 
Back
Top