我在 asp.net 中有一个图像组件,如下所示:
<div id="imgOperatorLogoContainer">
<asp:Image ID="imgOperatorLogo" runat="server" ToolTip="bla bla"
AlternateText="bla bla" ImageUrl="~/Images/c"
Width="170px" Height="191px" />
</div>
如您所见,我为这张图片设置了宽度和高度,但是通过这样做,face-images.jpg (3*170 = 510 * 191) 在元素区域中被拉伸了!
但我不想要这种行为,因为 face-images.jpg 里面包含 3 张图像(170*191),我想用 css 和 jquery 控制它们的定位!
我知道我们可以通过 div 元素来完成这项工作-> 但是 asp.net 的图像组件呢!
渲染后的图像如下(html):
<img style="height: 191px; width: 170px;" alt="bla bla" src="Images/face-images.jpg" title="bla bla" id="imgOperatorLogo">
但为什么下面的 css 不适用于此图像:
#imgOperatorLogo
{
background-position: 0px 0px;
}
或者
#imgOperatorLogo
{
background-position: -170px 0px;
}
或者
#imgOperatorLogo
{
background-position: -340px 0px;
}
我们可以通过备用 div 解决这个问题 - > 但是这样我们会丢失 alt 文本,我认为这对SEO
很重要
,提前谢谢