当前位置:首页 > 科技动态 > 正文

如何设置鼠标停留按钮变亮

如何设置鼠标停留按钮变亮

要设置鼠标停留在按钮上时按钮变亮,通常需要使用HTML和CSS来控制。以下是一个简单的示例,展示了如何通过CSS设置鼠标悬停时按钮变亮的效果。HTML部分:```htm...

要设置鼠标停留在按钮上时按钮变亮,通常需要使用HTML和CSS来控制。以下是一个简单的示例,展示了如何通过CSS设置鼠标悬停时按钮变亮的效果。

HTML部分:

```html

Button Hover Example

```

CSS部分(保存为`styles.css`):

```css

.hover-button {

background-color: 4CAF50; / Green background /

color: white; / White text /

padding: 15px 32px; / Padding around the text /

text-align: center; / Center the text /

text-decoration: none; / Remove underline from text /

display: inline-block; / Inline block display /

font-size: 16px; / Font size /

margin: 4px 2px; / Margin around the button /

cursor: pointer; / Change cursor to pointer /

border: none; / Remove border /

border-radius: 8px; / Rounded corners /

transition: background-color 0.3s; / Smooth transition for background-color change /

最新文章