如何调整 HTML 表格中原始图像的大小?

发布于 2024-08-19 22:09:36 字数 1979 浏览 6 评论 0原文

我用 HTML 创建了一个包含 4 行和 16 列的表格,并在一个单元格中插入了图像,在另一个单元格中插入了文本,直到拥有所有行和列。请参阅下面的我的代码。我的问题出在图像上:图像尺寸太大。我不知道如何让它达到缩略图的大小。此外,文本并不位于图像旁边。注意:图像在左侧,文字在图像右侧。任何帮助将不胜感激。

<html>
<head>
<title> Cameron Cookies </title>
</head>


<body>
<table cellspacing="0" cellpadding="0">
    <tr>
        <td><img src="j0175514.jpg" alt="Chocolate cookies"></img></td>
        <td>Chocolate</td>
        <td><img src="j0408843.jpg" alt="Chocolate Nut cookies"></img></td>
        <td>Chocolate Nut</td>
    </tr>
    <tr>
        <td><img src="j0428480.jpg" alt="Macadamia Nut cookies"></img></td>
        <td>Macadamia Nut</td>
        <td><img src="j0182695.jpg" alt="Oatmeal Raisin cookies"</img></td>
        <td>Oatmeal Raisin</td>
    </tr>
    <tr>
        <td><img src="j0428480.jpg" alt="M & M cookies"</img></td>
        <td>M & M's</td>
        <td><img src="j0440992.jpg" alt="White Chocolate cookies"</td>
        <td>White Chocolate</td>
    </tr>
    <tr>
        <td><img src="j0387871.jpg" alt="Chocolate Pecan cookies"</img></td>
        <td>Chocolate Pecan</td>
        <td><img src="j0425515.jpg" alt="Chocolate Hazelnut cookies"</img></td>
        <td>Chocolate Hazelnut</td>
    </tr>
</table>
</br>Cookies are a great gift idea that everybody loves. Just give us a call or send us an e-mail 24 hours in advance and we'll create
a lovely gift bag or basket filled with an assortment of fresh, homemade cookies.
Thanks for visiting our website and be sure to come visit us in person here in Portland, Maine.
To place an order, click here. </p>
</body>

</html>

I created a table with 4 rows and 16 columns in HTML and I inserted an image in one cell and text in another until I had all my rows and columns. See my code below. My problem lies with the image: the image size is too big. I don't know how to get it to about the size of a thumbnail. Also the text isn't sitting right next to the image. Note: the image is on the left and the text is on the right side of the image. Any help would be greatly appreciated.

<html>
<head>
<title> Cameron Cookies </title>
</head>


<body>
<table cellspacing="0" cellpadding="0">
    <tr>
        <td><img src="j0175514.jpg" alt="Chocolate cookies"></img></td>
        <td>Chocolate</td>
        <td><img src="j0408843.jpg" alt="Chocolate Nut cookies"></img></td>
        <td>Chocolate Nut</td>
    </tr>
    <tr>
        <td><img src="j0428480.jpg" alt="Macadamia Nut cookies"></img></td>
        <td>Macadamia Nut</td>
        <td><img src="j0182695.jpg" alt="Oatmeal Raisin cookies"</img></td>
        <td>Oatmeal Raisin</td>
    </tr>
    <tr>
        <td><img src="j0428480.jpg" alt="M & M cookies"</img></td>
        <td>M & M's</td>
        <td><img src="j0440992.jpg" alt="White Chocolate cookies"</td>
        <td>White Chocolate</td>
    </tr>
    <tr>
        <td><img src="j0387871.jpg" alt="Chocolate Pecan cookies"</img></td>
        <td>Chocolate Pecan</td>
        <td><img src="j0425515.jpg" alt="Chocolate Hazelnut cookies"</img></td>
        <td>Chocolate Hazelnut</td>
    </tr>
</table>
</br>Cookies are a great gift idea that everybody loves. Just give us a call or send us an e-mail 24 hours in advance and we'll create
a lovely gift bag or basket filled with an assortment of fresh, homemade cookies.
Thanks for visiting our website and be sure to come visit us in person here in Portland, Maine.
To place an order, click here. </p>
</body>

</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

唯憾梦倾城 2024-08-26 22:09:36

大多数浏览器会自动将图像大小调整为 标签

指定后,宽度和高度属性会告诉用户代理覆盖自然图像或对象大小以支持这些值。

当对象是图像时,它会被缩放。用户代理应尽力缩放对象或图像以匹配作者指定的宽度和高度。
图像、对象和小程序的视觉呈现< /p>

,正确的方法是将原始图像调整为所需的尺寸。

因此,如果您需要 160 x 120 图像,而您拥有 1600 x 1200 图像,请继续创建调整大小的图像并在源中引用该图像。

这样做将有助于更快地加载页面,因为图像文件现在将比原始文件小得多

Most browsers will automatically resize an image to the dimensions specified in the width and height attributes of the <img> tag:

When specified, the width and height attributes tell user agents to override the natural image or object size in favor of these values.

When the object is an image, it is scaled. User agents should do their best to scale an object or image to match the width and height specified by the author.
Visual presentation of images, objects, and applets

However, the right way to do this is to resize the original images to the desired dimensions.

So, if you need a 160 x 120 image and instead you have a 1600 x 1200 image, go ahead and create the resized image and reference that in the source.

Doing so will help the page load faster because the image file will now be much smaller than the original.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文