gpt4 book ai didi

html - 使用 CSS Sprite 输入图像类型

转载 作者:行者123 更新时间:2023-12-02 04:34:53 28 4
gpt4 key购买 nike

我正在创建一个引用包含多个图标的图像的 ImageButton。我试图通过定位背景图像来显示正确的图标,但这不起作用。以下是我创建 ImageButton 的方法:

ImageButton closeButton = new ImageButton();
closeButton.CommandName = "CloseItem";
closeButton.ID = "BtnClose";
closeButton.Width = 16;
closeButton.Height = 16;
closeButton.ImageUrl = "/_layouts/15/1031/images/formatmap16x16.png?rev=23.gif";
closeButton.Style.Add(HtmlTextWriterStyle.Top, "-115");
closeButton.Style.Add(HtmlTextWriterStyle.Left, "-275");
closeButton.OnClientClick = btn.OnClientClick;
this.Controls.Add(closeButton);

生成以下 HTML:

<input type="image" 
name="ctl00$ctl40$g_8cd9fd5c_6191_46af_bf6a_ac27c5fb0e80$ctl00$toolBarTbl$RightRptControls$ctl02$BtnClose"
id="ctl00_ctl40_g_8cd9fd5c_6191_46af_bf6a_ac27c5fb0e80_ctl00_toolBarTbl_RightRptControls_ctl02_BtnClose"
src="/_layouts/15/1031/images/formatmap16x16.png?rev=23.gif"
onclick="STSNavigate('http:\u002f\u002fespseis13\u002fsharechange\u002fdefault.aspx');return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$ctl40$g_8cd9fd5c_6191_46af_bf6a_ac27c5fb0e80$ctl00$toolBarTbl$RightRptControls$ctl02$BtnClose&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))"
style="height:16px;width:16px;top: -115px;left: -275px">

我显示的是这张图片:

enter image description here

我无法轻易切换输入类型,因为它需要属性 CommandName = "CloseItem"有谁知道,我如何移动(而不是缩放!)由 image 类型的 input 引用的图像?

最佳答案

实际上,可以使用 CSS Sprite 作为图像类型的输入;但作为背景图片。

您可以将透明 图像分配给src 属性并使用background为输入元素添加/定位背景图像的属性。

例如:

<input type="image" src="path/to/transparent.png" alt="Cut" />
input[type="image"] {
width: 24px;
height: 26px;
border: 1px solid gray;
background: url(http://i.stack.imgur.com/byld6.png) -60px 0 no-repeat;
}

WORKING DEMO .

关于html - 使用 CSS Sprite 输入图像类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22202554/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com