有些时候我们在给按钮赋值内容后,还想在文字后面加一个指示图片,使按钮作用更醒目。
没加图片前如图:
添加图片后如图:
代码如下:
<asp:Button runat="server" ID="btnPopupMenu" Text="操作方式"
Style="background-color: Transparent;background-image: url(/images/movenext1.gif); background-position: right center;background-repeat: no-repeat" />
样式解释:
background-color: Transparent; // 使背景色透明
设置或检索对象的背景颜色。当背景颜色与背景图像( background-image )都被设定了时,背景图片将覆盖于背景颜色之上。
background-image: url(/images/movenext1.gif); // 指定图片地址
background-position: right center; // 背景图片将被居右定位
设置或检索对象的背景图像位置。必须先指定 background-image 属性。该属性定位不受对象的补丁属性( padding )设置影响。
background-repeat: no-repeat // 背景图像不平铺
设置或检索对象的背景图像是否及如何铺排。必须先指定对象的背景图像( background-image )。