Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > HTML > HTML Code Clinic
|
HTML Code Clinic Do you have some HTML code you'd like to share and get suggestions from others for tweaking or improving it? This discussion is the place.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the HTML Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 19th, 2003, 03:23 AM
Authorized User
 
Join Date: Jul 2003
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to automatically modify picture size in table

I want to put a picture in a table,like follows:
<table border=0 cellPadding=0 bgcolor=#ffffff cellSpacing=0 width=500 align=center>>
  <table border=0 cellPadding=0 cellSpacing=0 width=95% align=center>
     <tr>
        <td width=30%>
         <p><image src="ss.jpg"> align="center"></p>
          <p><%=rs("content")%></p>
          </p>
         </td>
     </tr>
   </table>
  ....
</table>

the the size of picture "ss.jpg" is larger than td 's width,I want to make ss.jpg to automatically resize it's size in order to fill into table and size of table remains its original size,But I found it doesn't work,the "ss.jpg" didn't resize it's size and make table to longer.
How to do it?

Any idea will be appreciated!

 
Old November 19th, 2003, 11:04 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can specify just about any object's width and height to percentages and it will size accordingly. Try setting the picture to 100% width instead of a pixel value. No gaurantees regarding browser compatibility however.

Peter
------------------------------------------------------
Work smarter, not harder.
 
Old November 19th, 2003, 05:28 PM
richard.york's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Quote:
quote:
You can specify just about any object's width and height to percentages and it will size accordingly. Try setting the picture to 100% width instead of a pixel value. No gaurantees regarding browser compatibility however.
That method works much better if you do it with CSS and set the height attribute to 'auto' which should preserve the aspect ratio. In my experience setting only the width attribute to a percentage, or even to pixels caused some browsers to choke. Well its a double edged sword.. the CSS should work on all the new browsers and most, if not all, flavors of IE.. but won't work on the older ones. This is also standards compliant as the old width, height attributes on their own are deprecated. e.g. width=100 height=20

<img src='some_picture' style='width: 100%; height: auto;' />

: )
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::





Similar Threads
Thread Thread Starter Forum Replies Last Post
PhotoAlbums/default.aspx - Picture size dbcook8 BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 November 14th, 2008 04:26 PM
How to dynamically modify a table... roopesh ASP.NET 1.0 and 1.1 Basics 9 January 16th, 2007 12:05 PM
Modify field properties in linked table RickD Access 1 September 8th, 2006 06:58 AM
Can't Modify or Delete table PatYoda SQL Server 2000 3 December 3rd, 2004 09:41 AM
Cannot modify data in table residing on SQL Serv sherr8 SQL Server 2000 14 June 6th, 2003 04:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.