赞
踩
<div class="box">
<h2>标题</h2>
<p>文本</p>
<div class="box2">X</div>
</div>
.box{
position: relative;
width: 300px;
height: 150px;
background-image: linear-gradient(
#547ad4,
#7954df
);
border-radius: 20px;
color: #ffffff;
text-align: center;
}
.box2{
position: absolute;
right: 10px;
top: 10px;
width: 30px;
height: 30px;
background-color: #fff;
border-radius: 50%;
line-height: 30px;
text-align: center;
color: #000;
}
const box=document.querySelector('.box')
const box2=document.querySelector('.box2')
box2.addEventListener('click',function(){
box.style.display='none'
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box{
position: relative;
width: 300px;
height: 150px;
background-image: linear-gradient(
#547ad4,
#7954df
);
border-radius: 20px;
color: #ffffff;
text-align: center;
}
.box2{
position: absolute;
right: 10px;
top: 10px;
width: 30px;
height: 30px;
background-color: #fff;
border-radius: 50%;
line-height: 30px;
text-align: center;
color: #000;
}
</style>
</head>
<body>
<div class="box">
<h2>标题</h2>
<p>文本</p>
<div class="box2">X</div>
</div>
<script>
const box=document.querySelector('.box')
const box2=document.querySelector('.box2')
box2.addEventListener('click',function(){
box.style.display='none'
})
</script>
</body>
</html>
⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️
制作不易,给个赞吧!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。