HTML表格定位问题
我主要不是一名 html 程序员,但我使用 HTML 来格式化 iPhone 中一个屏幕的显示。所以我所拥有的应该是一个段落,比如在右上角显示嵌入图像,这样在图像旁边,文本就会换行并且不会重叠,但一旦出现就会继续向右。在图像下方。
我需要在下面发布一个评论表,所以知道我的视图是 728 像素宽,我做了
<table width="768">
当我在较小的(240 像素宽)视图中执行此代码时,评论出现在图像下方,但在较大的视图中,事实并非如此。有谁知道为什么会发生这种情况?
这是我正在使用的 html 示例:
<body bgcolor="#FFFFFF">
<p>
<img src="http://www.smspal.com/iPhonePhoto.jpg" width="320" height="480" align="right">
Tweet
</p>
<table width="728" cellpadding="3" cellspacing="0" >
<tr>
<td>
<b>
<font size="2">Parent1 Parent1</font>
</b>
</td>
<td>
<p align="right"><font size="1">Tue. May 3, 2011 at 3:47 PM</font></p>
</td>
</tr>
<tr>
<td colspan="2">
<p align="left">
<font size="2">Add a comment</font>
</p>
</td>
</tr>
</table>
<hr noshade size="1" />
</body>
I'm not primarily an html programmer, but I'm using HTML to format the display of one of my screens in iPhone. So what I have is something that is supposed to be a paragraph like display with an embedded image in the top right, so that while next to the image, the text wraps and doesn't overlap, but will continue to the right once it is below the image.
I hen need a table of comments posted below that, so knowing that my view is 728 pixels wide, I did
<table width="768">
When I do this code in my smaller (240 px wide) view, the comments appear below the image, but in the larger view, it doesn't. Anyone know why this might happen?
Here's a sample of the html I'm using:
<body bgcolor="#FFFFFF">
<p>
<img src="http://www.smspal.com/iPhonePhoto.jpg" width="320" height="480" align="right">
Tweet
</p>
<table width="728" cellpadding="3" cellspacing="0" >
<tr>
<td>
<b>
<font size="2">Parent1 Parent1</font>
</b>
</td>
<td>
<p align="right"><font size="1">Tue. May 3, 2011 at 3:47 PM</font></p>
</td>
</tr>
<tr>
<td colspan="2">
<p align="left">
<font size="2">Add a comment</font>
</p>
</td>
</tr>
</table>
<hr noshade size="1" />
</body>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在表格上指定绝对像素大小以匹配特定屏幕的像素宽度。尺寸是绝对的,因此在较小的屏幕尺寸上,其左侧或右侧无法显示更多内容,因此它除了向下无处可去。
尝试使用百分比宽度,因为这是一个相对大小,可以符合许多不同的屏幕尺寸。
Your giving an absolute pixel size on your table to match the pixel width of a specific screen. The size is absolute so on a smaller screen size nothing more can be displayed to the left or right of it so it has nowhere to go but down.
Try using a percentage width as that is a relative size that will conform to many different screen sizes.
为什么不将图像放在表格中呢?您可以使用 colspan 属性将图像保持在右角。
Why don't you just put the image inside the table? You can use the colspan attribute to keep the image in the right corner.