html按键颜色设置,HTML如何更改按键颜色并保持?

你是想用css实现,还是js。还有你代码写的不对最后一个<body>,应该是</body><buttontype="submit",id="d1"class="buttonitem1"οnclick="document.getElementById('d1').style.background='#ffa200';document.getElementById('d2').style.background='#0a56bb';document.getElementById('d3').style.background='#0a56bb';">第一个按钮</button><buttontype="submit",id="d2"class="buttonitem2"οnclick="document.getElementById('d2').style.background='#ffa200';document.getElementById('d1').style.background='#0a56bb';document.getElementById('d3').style.background='#0a56bb';">第二个按钮</button><buttontype="submit",id="d3"class="buttonitem3"οnclick="document.getElementById('d3').style.background='#ffa200';document.getElementById('d2').style.background='#0a56bb';document.getElementById('d1').style.background='#0a56bb';">第三个按钮</button>设置一个id,onclick是点击事件,点击后变色,其他回复原来颜色,每个点击事件有三个document,第一个是变色,后两个是恢复,如果不要他恢复就删掉。这只是简单js写法,适合初学但不实用,可以自己先研究一下,不明白的地方可以再问我

阅读全文 >

以下是一个简单的 HTML 程序,包含一个圆形美化后的按键: ```html <!DOCTYPE html> <html> <head> <title>圆形美化后的按键</title> <style> .button { background-color: #4CAF50; /* 设置背景颜色 */ border: none; /* 去掉边框 */ border-radius: 50%; /* 将按钮变成圆形 */ color: white; /* 设置文字颜色 */ padding: 15px 32px; /* 设置内边距 */ text-align: center; /* 文字居中 */ text-decoration: none; /* 去掉下划线 */ display: inline-block; /* 将按钮变成行内元素 */ font-size: 16px; /* 设置文字大小 */ margin: 4px 2px; /* 设置外边距 */ cursor: pointer; /* 设置鼠标样式 */ transition-duration: 0.4s; /* 设置过渡动画时间 */ } .button:hover { background-color: #008CBA; /* 鼠标悬浮时,设置背景颜色 */ color: white; /* 鼠标悬浮时,设置文字颜色 */ } </style> </head> <body> <button class="button">点击我</button> </body> </html> ``` 这个程序定义了一个名为 `button` 的 CSS 样式类,用于美化按钮。具体来说,它设置了以下属性: - `background-color`:设置背景颜色为绿色。 - `border`:去掉边框。 - `border-radius`:将按钮变成圆形。 - `color`:设置文字颜色白色。 - `padding`:设置内边距。 - `text-align`:文字居中。 - `text-decoration`:去掉下划线。 - `display`:将按钮变成行内元素。 - `font-size`:设置文字大小。 - `margin`:设置外边距。 - `cursor`:设置鼠标样式。 - `transition-duration`:设置过渡动画时间为 0.4 秒。 然后,将这个样式类应用到一个 `button` 元素上,即可得到一个圆形美化后的按键。当鼠标悬浮在按钮上时,它的背景颜色和文字颜色会发生变化,以提供一些反馈。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值