Write a csss code to change button color when hover
- User
Write a csss code to change button color when hover
- Assistant
To change the button color when hovering over it using CSS, you can use the
:hoverpseudo-class. Here's an example CSS code that demonstrates this:button { background-color: #4CAF50; /* Green background color */ color: white; /* White text color */ padding: 10px 20px; /* Padding around the button */ border: none; /* Remove button border */ cursor: pointer; /* Change cursor to pointer on hover */ } button:hover { background-color: #45a049; /* Darker green background color on hover */ }In this CSS code:
-
The
buttonselector targets all<button>elements.background-color: #4CAF50;sets the default background color of the button to green.color: white;sets the text color to white.- adds padding around the button for better visual appearance.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.