Community Forum

Ask questions, share knowledge, and interact with the community

Post a New Question

How can I add a hover effect to my button in CSS?

John Doe asked:

I am trying to create a hover effect on a button but I can't get it to work properly. Can anyone help me?

Jane Smith replied:

To add a hover effect, use the :hover pseudo-class in your CSS. Here's an example:

button:hover {
    background-color: green;
    color: white;
}
                            
How can I center a div in CSS?

Sarah Lee asked:

I'm struggling to center a div both vertically and horizontally on the page. Any tips?

Mark Davis replied:

You can use flexbox to easily center a div. Here's a simple solution:

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}