Javascript 背景模糊动画

Javascript 背景模糊动画,javascript,html,css,function,animation,Javascript,Html,Css,Function,Animation,我目前有一些javascript函数应用于触发弹出窗口的多个按钮,显示更多内容。我想做一个函数,一旦点击任何一个按钮,就会触发一个模糊背景动画,另一个弹出窗口从顶部滑入的动画。任何帮助都将不胜感激 document.querySelectorAll(".button a").forEach((a)=>{a.addEventListener("click",toggle);}); document.querySelectorAll(".popup a:last-child").forEach

我目前有一些javascript函数应用于触发弹出窗口的多个按钮,显示更多内容。我想做一个函数,一旦点击任何一个按钮,就会触发一个模糊背景动画,另一个弹出窗口从顶部滑入的动画。任何帮助都将不胜感激

document.querySelectorAll(".button a").forEach((a)=>{a.addEventListener("click",toggle);});
document.querySelectorAll(".popup a:last-child").forEach((a)=>{a.addEventListener("click",close);});

function toggle()
{
    this.parentElement.nextElementSibling.classList.toggle("active"); //popup is sibling of a's parent element
}
function close()
{
    this.parentElement.classList.toggle("active"); // .popup
}
这是该函数的CSS

.popup
{
  display: none;
  visibility: hidden;
  position: fixed;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 600px;
  padding: 50px;
  box-shadow: 0 5px 30px rgba(0,0,0,.30);
  background: #A6A6A6;

}
.active
{
 display: block;
 top: 50%;
 visibility: visible;
 left: 50%;
}
以及HTML:

<div class="container">

            <div class="box button">
                <a href="#">HURRICANE TRACK</a>
            </div>
            <div class="popup">
                <h2>HURRICANE TRACKING</h2>
                <video src="python_movies/hurricanetrack.mov"controls></video>
                <p>
                    A Python project that prompts the user for a file containing hurricane information in order to form a dictionary that contains the names of hurricanes, the years the hurricanes occurred, and the correspoding data for each of the hurricanes, including the trajectory, longitude, lattitude, and wind speed. The program graphs all of the corresponding information by adding the information on a table, graphing the trajectory of the hurricanes, and plotting the information in a graph according to the wind speed.
                </p>
                <a href="#" style="border: 2px solid; padding: 5px;">CLOSE</a>
            </div>

            <div class="box button">
                <a href="#">NINE MEN'S MORRIS</a>
            </div>
            <div class="popup">
                <h2>NINE MEN'S MORRIS</h2>
                <video src="python_movies/ninemensmorris.mov"controls></video>
                <p>
                    A Python Project that runs the game, Nine Men's Morris. Nine Men's Morris is a two player game that combines elements of tic-tac-toe and checkers. The board consists of a grid with twenty-four intersections or points. Each player has nine pieces. Players try to form 'mills'—three of their own men lined horizontally or vertically—allowing a player to remove an opponent's man from the game. A player wins by reducing the opponent to two pieces (where they could no longer form mills and thus be unable to win), or by leaving them without a legal move. The game proceeds in three phases, however, this project handles the first phase.
                </p>

                <a href="#" style="border: 2px solid; padding: 5px;">CLOSE</a>
            </div>

飓风追踪

一个Python项目,提示用户输入一个包含飓风信息的文件,以便形成一个字典,其中包含飓风的名称、飓风发生的年份以及每个飓风的相应编码数据,包括轨迹、经度、纬度和风速。该程序通过在表格上添加信息、绘制飓风的轨迹以及根据风速在图表中绘制信息来绘制所有相应的信息。

九男子莫里斯 一个运行游戏的Python项目,九人莫里斯。Nine Men's Morris是一款两人游戏,结合了井字游戏和跳棋的元素。电路板由24个交点或点组成的网格组成。每个选手有九个棋子。玩家试图组成“磨坊”——三名自己的人水平或垂直排列,允许玩家将对手的人移出游戏。玩家通过将对手减少为两个棋子(在这两个棋子中,他们无法再形成磨坊,因此无法获胜)或在没有合法移动的情况下离开他们来获胜。游戏分三个阶段进行,然而,这个项目处理第一阶段。

$(文档).ready(函数(){
$(“.button”)。单击(函数(){
$(“.popup”).toggleClass(“活动”);
});
});
.popup
{
显示:无;
可见性:隐藏;
位置:固定;
左:50%;
转换:翻译(-50%,-50%);
宽度:600px;
填充:50px;
盒影:0 5px 30px rgba(0,0,0,30);
背景:#A6;
}
.主动
{
显示:块;
最高:50%;
能见度:可见;
左:50%;
}

你好,你好吗


请参阅此片段。它会帮助你的

$(文档).ready(函数(){
$(“.button”)。单击(函数(){
$(“.popup”).toggle(800);
});
});
.popup
{
显示:无;
能见度:可见;
位置:固定;
左:0;
宽度:100%;
填充:0;
背景色:rgba(0,0,0,0.5);
z指数:9999999;
身高:100%;
}

你的虚拟文本

您可以这样做,下面是示例代码

$(文档).ready(函数(){
$(“.button”)。单击(函数(){
$(“.popup”).slideToggle(500);
});
});
.popup{
显示:无;
能见度:可见;
位置:固定;
左:0;
宽度:100%;
填充:0;
盒影:0 5px 30px rgba(0,0,0,30);
背景:#A6;
z指数:9999999;
身高:100%;
}

你的虚拟文本

发布HTML代码也有助于解决问题