I currently have a 'p' element containing some text nested inside of a div element. I need the opacity of the div's background to change upon hover without it affecting the opacity of the text in the 'p' element. Attached is an example of what I have
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="container">
<p class="text">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum perferendis quaerat necessitatibus
sed blanditiis assumenda.</p>
</div>
<div class="container1">
<p class="text1">Lorem ipsum dolor sit amet consectetur adipisicing elit. Eum perferendis quaerat necessitatibus
sed blanditiis assumenda.</p>
</div>
</body>
</html>
CSS
:root {
--Soft-red: hsl(10, 79%, 65%);
--Cyan: hsl(186, 34%, 60%);
}
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
background-color: var(--Soft-red);
}
.container {
margin-top: 20px;
height: 80vh;
width: 80vw;
background-color: rgba(var(--Cyan), 0.5);
transition: background-color 0.5s;
}
.container:hover {
background-color: rgb(0, 255, 255, 0.1)
}
.container1 {
margin-top: 20px;
height: 80vh;
width: 80vw;
background-color: var(--Cyan);
transition: opacity 0.5s;
}
.container1:hover {
opacity: 0.1;
}
So far I've tried to give the 'p' element its own hover properties but that solution does not work. I tried changing my background-color property to rgba() but because I'm using css variables I can't change the opacity value.