使用html5写一个刮刮乐奖券的布局
当然,以下是一个简单的刮刮乐奖券的前端HTML5和CSS布局示例:
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>刮刮乐奖券</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="scratch-card">
<div class="scratch-area">
<div class="overlay"></div>
<div class="prize">一等奖</div>
</div>
<div class="info">
<p>刮开涂层,赢取大奖!</p>
</div>
</div>
</body>
</html>
CSS (styles.css):
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.scratch-card {
width: 200px;
height: 300px;
background-color: #ffffff;
border-radius: 10px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
position: relative;
overflow: hidden;
}
.scratch-area {
width: 100%;
height: 200px;
background-color: #f0f0f0;
position: relative;
border-bottom: 1px solid #e0e0e0;
}
.overlay {
width: 100%;
height: 100%;
background-image: linear-gradient(45deg, #888 25%, transparent 25%, transparent 75%, #888 75%, #888),
linear-gradient(45deg, #888 25%, transparent 25%, transparent 75%, #888 75%, #888);
background-size: 20px 20px;
background-position: 0 0, 10px 10px;
position: absolute;
top: 0;
left: 0;
}
.prize {
font-size: 24px;
font-weight: bold;
color: #ff0000;
text-align: center;
line-height: 200px;
position: relative;
}
.info {
padding: 10px;
text-align: center;
}
这个示例创建了一个简单的刮刮乐奖券布局。.scratch-card 是整个奖券的容器,.scratch-area 是包含刮奖区域的容器,.overlay 是覆盖在刮奖区域上的涂层,.prize 是涂层下面的奖项文本,.info 是奖券下方的信息区域。
请注意,这个示例只提供了静态的布局和样式,没有实现刮奖的动态效果。如果你需要实现刮奖的功能,你可能需要使用JavaScript和Canvas API来检测用户的触摸或鼠标事件,并动态地移除涂层以显示奖项。
浙公网安备 33010602011771号