html - 图片标签中的背景位置

标签 html css image background tags

我使用了 background-position: (0)px (0)px;在 css 中多次与 background-image: url(.....); 但是我想知道我是否可以在 IMAGE 标签中使用这个 Css 属性。其实我想要的是这样的东西;

<a href="(some line page.html)" target="_blank"><img style="float: left; background-position: 0px 0px;" src="images/variousthumbnails.jpg" alt="Thumbnail 1" width="100" height="98" /></a>

“variousthumbnails.jpg”包含 9 个图像,每个宽度为 100px,高度为 98px。我想在此图像标签中显示位于“0px 0px”的第一个缩略图,其他的以此类推。 如果可能的话,请告诉我。

我不能在 css 中使用背景图像。

谢谢。

最佳答案

我相信你指的是一种叫做 CSS Sprites 的方法。

您使用一张包含许多小图片的大图片,因此您只需为页面的所有用途加载一张图片。

这里有一个很好的概述:CSS - using one background image with multiple images on it

关于html - 图片标签中的背景位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19720687/

相关文章:

html - 添加指向叠加图像的链接

html - 是否可以阻止从我的站点保存图像?

html - 尝试对齐 div 中的图像

jQuery 更改单击图像的图像 onclick 和其他图像

html - 如何对齐表格

javascript - 使用 jquery 从 td 元素中删除 div 和 table

c# - 如何让 C# 使用基于 css/svg 字体系列字符串的字体?

html - 是否可以使用 CSS 变换和过渡来缩放 SVG 图像?

css - 如何在 less 中使用 symbol 作为 var?

具有相对路径的Java Composite backgroundimage