100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > html修改按钮背景颜色 html鼠标悬浮在按钮上 让按钮背景变色

html修改按钮背景颜色 html鼠标悬浮在按钮上 让按钮背景变色

时间:2018-09-14 17:42:37

相关推荐

html修改按钮背景颜色 html鼠标悬浮在按钮上 让按钮背景变色

我写了个例子给你,不肯定是不是你要实现的效果哈。(基于c#)

前端代码:

Grid

StackPanel

Button Background=Blue Name=btn Width=100 Height=100 Click=btn_Click/Button

TextBlock Name=txt Text=null HorizontalAlignment=Center/

/StackPanel

/Grid

后台代码

public partial class Page1 : Page

{

public Page1()

{

InitializeComponent();

}

string tag=string.Empty;

private void btn_Click(object sender, RoutedEventArgs e)

{

Button btn = sender as Button;

if (tag == string.Empty)

{

btn.Background = new SolidColorBrush(Colors.Red);

txt.Text = 0;

tag = 0;

}

else

{

btn.Background = new SolidColorBrush(Colors.Blue);

txt.Text = null;

tag = string.Empty;

}

}

}

取消

评论

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。