如何使用css将背景图像应用于按钮 [英] How to apply background image to button using css

查看:76
本文介绍了如何使用css将背景图像应用于按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中我使用按钮。我想将背景图像应用于按钮即时编写代码,但它不显示背景图像到button.i不想使用图像按钮控件。

css文件

< pre lang =CSS>。按钮
{

background-image url('/ img / button_2.png /');


}



源代码

< asp:按钮ID =   Button1 runat =   server CssClass =   buttons Text =   edit /> 

解决方案

为什么不使用 ImageButton [ ^ ]控制?


使用其 CssClass 属性表示你有如下按钮



 myBtn  
{
background transparent url('myImage.png')no-repeat;
}



现在将此类应用于 CssClass 属性中的按钮。



使用图像按钮 [ ^ ]控制而不是CSS。



此外,请参考:

在ASP.NET中设计选项卡的简单方法 [ ^ ]

本文将介绍如何使用Buttons,MultiView Control和CSS在ASP.NET页面中创建选项卡


在CSS类中尝试这样的事情



 .buttons 
{


background:url(images / orange_button_bg.gif)no-repeat 25%50%#FF8800;
}


In my application i m using button. i want to apply background image to button i m writing below code but it does not display background image to button.i dont want to use image button control.
css file

.buttons
{

background-image:url('/img/button_2.png/') ;


}


source code

<asp:Button ID="Button1" runat="server" CssClass="buttons" Text="edit" />

解决方案

Why not use an ImageButton [^]control?


Use its CssClass property say you have button like following

.myBtn
{
   background:transparent url('myImage.png') no-repeat;
}


now apply this class in your button in CssClass property.

Use Image Button[^] control instead of CSS.

In addition, please refer:
Simple way to Design Tabs in ASP.NET[^]
This article will show how to Create Tabs in ASP.NET page using Buttons, MultiView Control and CSS


Try something like this in your CSS class

.buttons
{
 

 background: url(images/orange_button_bg.gif) no-repeat 25% 50% #FF8800;
}


这篇关于如何使用css将背景图像应用于按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆