html鼠标悬浮在按钮上,让按钮背景变色

已举报 回答
html鼠标悬浮在按钮上,让按钮背景变色
问在线客服
扫码问在线客服
  • 回答数

    8

  • 浏览数

    3,400

8个回答 默认排序
  • 默认排序
  • 按时间排序

已采纳
鼠标放在button上改变颜色,HTML
button onmouseover=this.style.backgroundColor='red'; onmouseout=this.style.backgroundColor=''; 确定/button
取消 评论
value=“”,这是时候value的值 style=background:url('zc.jpg') no-repeat; width:180px; height:37px;把引号加上就可以了
取消 评论
我写了个例子给你,不肯定是不是你要实现的效果哈。(基于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;
}
}
}
取消 评论
利用a的四个伪类就行了 下面是四个伪类的介绍:
A的四个伪类
:link 未被访问前的样式表属性
:visited 其链接地址已被访问过时的样式表属性
:active 用户激活(在鼠标点击与释放之间发生的事件)时的样式表属性
:hover 鼠标悬停时hover
写法:a:link/:visited/:hover/:active 或者a:link/:visited/:active/:hover 顺序不能互换,有一个比较好记的口诀,就是:love -- hate
取消 评论
这个是j2se ~~~~CS结构的?
你是想问html的页面提示文字么?
加一个 input type=button value=按钮 title=提示文字 /
取消 评论
把下面代码直接保存为.html后缀名就可以了。。。记得给分就是了
!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
html xmlns=http://www.w3.org/1999/xhtml
head
meta http-equiv=Content-Type content=text/html; charset=gb2312 /
title无标题文档/title
/head
style
.adminbutton {border:#07A1EE 1px solid;background:#BFE7FA; height:22px;}
/style
bodybrbrbr
center
input type=button name=SubmitS value= 按 钮 class=adminbutton onMouseOut=this.style.backgroundColor='' onMouseOver=this.style.backgroundColor='#efefef' style=height:18px;padding-top:1px; width:
/center
/body
/html
取消 评论
在button属性里有个外观项,在里面选择你中意的样式后,在事件里面的
MouseMove里面添加 button.属性名 = 显示的内容; 试试看
取消 评论
导入import javax.swing.*;即可,不用导其它的外界包。
举例如下:
public class UI extends JFrame{
private JButton button;
public UI(){
button=new JButton();
button.setToolTipText(这是什么按钮?);
this.add(button);
this.setSize(200,300);
this.setDefaultCloseOperation(this.EXIT_ON_CLOSE);
this.setVisible(true);
}
public static void main(String[] args){
new UI();
}
}
取消 评论
ZOL问答 > 鼠标 > 其他分类 > html鼠标悬浮在按钮上,让按钮背景变色

举报

感谢您为社区的和谐贡献力量请选择举报类型

举报成功

经过核实后将会做出处理
感谢您为社区和谐做出贡献

扫码参与新品0元试用
晒单、顶楼豪礼等你拿

扫一扫,关注我们
提示

确定要取消此次报名,退出该活动?