Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS Hover Effect doesn't working as I want

I have two divs, one parent and one child. When hover the parent div element, i want to change background-color of parent div element. But hover effect only work if i hover on the child div and only changes the background color of child div element.

I want to change the background-color of parent div element when hover on it.

Here is my code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Button.js:

import React from "react";
import classes from "./Buttons.module.css";

export function ButtonHorizontal() {
  return (
    <div className={classes.buttonHorizontal}>
      <div className={classes.text}>CLICK</div>
    </div>
  );
}

and Buttons.module.css:

.buttonHorizontal {
  background-color: #ffffff2c;
  border-radius: 100px;
  text-decoration: none;
  display: inline-block;
  cursor: pointer;
  padding: 10px 25px;
}
.buttonHorizontal :hover {
  background-color: #ffffff98;
}
.text {
  font-size: 1.3rem;
  font-weight: 900;
  display: inline;
  padding-left: 10px;
  
}

>Solution :

You line .buttonHorizontal :hover should be .buttonHorizontal:hover without the empty space!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading