css 如何在javascript中更改backdrop-filter?

bvjveswy  于 2023-05-19  发布在  Java
关注(0)|答案(1)|浏览(163)

嗨,我不能改变backdrop过滤器与javascript请帮助我,谢谢。

<html>
<head>
<title>a problem</title>
<style>
 #div {
  width: 120px;
  height: 120px;
  backdrop-filter: blur(0); 
 }
</style>
</head>
<body>
 <div id="div"></div>
</body>
<script>document.getElementById("div").style.backdropfilter = "blur(15px)";</script>
</html>
smdnsysy

smdnsysy1#

更新CSS属性时必须使用camelCase:例如.backdropFilter

<html>
<head>
<title>a problem</title>
<style>
 #div {
  width: 120px;
  height: 120px;
  backdrop-filter: blur(0); 
 }

 body {  background: url(https://theoldreader.com/kittens/files/images/80144273@N00-2871547320/600x400.jpg) no-repeat }
</style>
</head>
<body>
 <div id="div"></div>
</body>
<script>document.getElementById("div").style.backdropFilter = "blur(15px)";</script>
</html>

相关问题