I have this simple example :
<html>
<head>
<style>
:root {
--textbox-box-shadow: none;
}
.example3 {
display: block;
border: 1px solid red;
padding: 10px;
box-shadow: var(--textbox-box-shadow);
}
.example3 input:focus {
--textbox-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px red;
}
</style>
</head>
<body>
<div class="example3">
Enter your name : <input>
</div>
</body>
</html>
I'm trying to make the 'div' glow when the input element inside it is focused.
The code doesn't work and I can't figure out why.
Btw when giving the variable an initial value of
inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px red;
instead of "none", the div does glow red.
How can I fix it ?
Edit:
Turns out that this actually creates a new local variable by the name "textbox-box-shadow".
.example3 input:focus {
--textbox-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px red;
}
Still the question stands, how can I make the outer div <div class="example3">
glow when input is focused with pure CSS and without using javascript (if that's possible)?