要将阴影附加到框,请使用JavaScript中的boxShadow属性。使用此属性,添加阴影的宽度以及颜色。
您可以尝试运行以下代码,以了解如何附加一个或多个阴影。
<!DOCTYPE html> <html> <head> <style> #box { border: thick solid green; width: 300px; height: 200px } </style> </head> <body> <div id="box">Demo Text</div> <br><br> <button type="button" onclick="display()">Add drop shadow</button> <script> function display() { document.getElementById("box").style.boxShadow = "20px 15px 25px orange"; } </script> </body> </html>