<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
* {
padding: 0;
margin: 0;
}
body {
position: relative;
}
.btn {
width: 100px;
height: 40px;
}
.btn,
.btn a {
display: block;
width: 100px;
height: 40px;
line-height: 40px;
text-align: center;
background: #ccc;
}
.Lbox {
width: 100%;
height: 100%;
display: none;
position: fixed;
background: #000;
opacity: 0.85;
}
.Ibtn {
width: 200px;
height: 200px;
margin: 0 auto;
margin-top: 10%;
position: relative;
background: #fff;
}
.Lcontent {
width: 100%;
height: 100%;
}
:target {
display: block;
}
</style>
</head>
<body>
<div class="Lbox" id="open">
<div class="Lcontent">
<div class="Ibtn">
</div>
</div>
</div>
<div class="btn">
<a href="#open">开灯</a>
</div>
</body>
</html>
CSS3target伪类元素选择实现类似灯箱效果
最新推荐文章于 2025-08-03 11:01:24 发布
本文介绍了一个简单的网页交互效果——点击按钮后显示一个带有开灯动画的页面。通过CSS样式控制页面元素的显示与隐藏,并利用HTML锚点定位来实现开灯效果。
4103

被折叠的 条评论
为什么被折叠?



