OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Why changing height affects the effect of boxShadow

  • Thread starter Thread starter Gauch
  • Start date Start date
G

Gauch

Guest
enter image description here

This is what it looks like, changing the height of the element results in the shadow effect also changed, out of the blue, please enlighten me, thank you.

Code:
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
                content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #shadow {
            width: 100px;
            height: 1px;
            background: #ccc;
            box-shadow: 0 0 10px red;
            margin: 60px;
        }
    </style>
    <script>
        function inputHandle(e) {
            document.getElementById('shadow').style.height = `${e.target.value}px`;
        }
    </script>
</head>
<body>
<label for="num">height</label>
<input type="number" value="1" id="num" oninput="inputHandle(event)">

<div id="shadow"></div>
</body>
</html>
<p><a href="https://i.sstatic.net/65unf0RB.gif" rel="nofollow noreferrer"><img src="https://i.sstatic.net/65unf0RB.gif" alt="enter image description here" /></a></p>
<p>This is what it looks like, changing the height of the element results in the shadow effect also changed, out of the blue, please enlighten me, thank you.</p>
<pre><code><!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#shadow {
width: 100px;
height: 1px;
background: #ccc;
box-shadow: 0 0 10px red;
margin: 60px;
}
</style>
<script>
function inputHandle(e) {
document.getElementById('shadow').style.height = `${e.target.value}px`;
}
</script>
</head>
<body>
<label for="num">height</label>
<input type="number" value="1" id="num" oninput="inputHandle(event)">

<div id="shadow"></div>
</body>
</html>
</code></pre>
Continue reading...
 

Latest posts

Top