点击一个div图层,在其上面弹出另一个div图层,用js怎么实现
1个回答
展开全部
两个div 先写好,一个先隐藏,点击后更改其属性,让其显示
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.outer{
position: relative;
数困 height: 300px;
迅毁 薯昌念width: 500px;
background-color: #097df3;
}
.d1{
display: none;
position: absolute;
height: 200px;
width: 300px;
top: 50px;
left: 100px;
background-color: #FF6C00;
}
</style>
</head>
<body>
<div class="outer" onclick="fn()">
<div class="d1"></div>
</div>
<script>
function fn(){
document.getElementsByClassName('d1')[0].style.display = "block";
}
</script>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询