<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML5 App Example</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.app-container {
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}
button {
padding: 10px 20px;
font-size: 16px;
cursor: pointer;
}
</style>
</head>
<body>
<div class="app-container">
<h1>HTML5 App</h1>
<p>This is a simple HTML5 app example.</p>
<button onclick="showMessage()">Click Me</button>
</div>
<script>
function showMessage() {
alert('Hello from HTML5 App!');
}
</script>
</body>
</html>
HTML 结构:
<!DOCTYPE html>
: 声明文档类型为 HTML5。<html lang="en">
: 设置页面语言为英语。<meta charset="UTF-8">
: 设置字符编码为 UTF-8。<meta name="viewport" content="width=device-width, initial-scale=1.0">
: 确保页面在移动设备上正确显示。<title>
: 设置页面标题。<style>
: 内联样式,用于美化页面。<div class="app-container">
: 包含应用的主要内容。<button onclick="showMessage()">
: 按钮点击时调用 JavaScript 函数。CSS 样式:
JavaScript:
function showMessage()
: 定义一个简单的 JavaScript 函数,在用户点击按钮时弹出提示框。上一篇:html怎么插入图片
下一篇:html a标签打开新窗口
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站