<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>My Interactive Web Page</title> <style> body { background-color: #f2f2f2; font-family: Arial, sans-serif; } h1 { text-align: center; color: #333; } p { font-size: 18px; line-height: 1.5; margin-bottom: 20px; } .container { max-width: 800px; margin: 0 auto; padding: 20px; } .button { display: inline-block; padding: 10px 20px; background-color: #333; color: #fff; text-align: center; text-decoration: none; font-size: 16px; border-radius: 5px; transition: background-color 0.3s ease; cursor: pointer; } .button:hover { background-color: #666; } </style></head><body> <div class="container"> <h1>Welcome to my interactive web page</h1> <p>This is a simple web page that demonstrates how to use HTML, CSS, and JavaScript to create an interactive user experience.</p> <p>Click the button below to change the background color of the page:</p> <button class="button" onclick="changeBackgroundColor()">Change Color</button> </div> <script> function changeBackgroundColor() { var body = document.querySelector('body'); body.style.backgroundColor = getRandomColor(); } function getRandomColor() { var letters = '0123456789ABCDEF'; var color = '#'; for (var i = 0; i < 6; i++) { color += letters[Math.floor(Math.random() * 16)]; } return color; } </script></body></html>根据以上代码插入适当的代码,显示更多的内容
时间: 2024-02-10 09:17:45 浏览: 26
可以在<div class="container">标签后面添加更多的HTML内容,例如:
<div class="container">
<h1>Welcome to my interactive web page</h1>
<p>This is a simple web page that demonstrates how to use HTML, CSS, and JavaScript to create an interactive user experience.</p>
<p>Click the button below to change the background color of the page:</p>
<button class="button" onclick="changeBackgroundColor()">Change Color</button>
<p>Here is some more content:</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<p>You can add as much content as you want here!</p>
</div>
相关问题
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Not found</title> </head> <body> <h1>Not found</h1> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Not found</title> </head> <body> <h1>Not found</h1> </body> </html>是一个HTML页面模板,它是一个简单的404页面,用于显示“Not found”错误信息。在这个模板中,<!DOCTYPE html>定义了文档类型,<html>标签定义了HTML文档的根元素,<head>标签定义了文档的头部部分,<meta charset="UTF-8">指定了文档的字符编码为UTF-8,<title>标签定义了文档的标题,<body>标签定义了文档的主体部分,<h1>标签定义了一个一级标题。
<!DOCTYPE html> ↵ ↵<html> ↵<head> ↵ <meta charset="utf-8" /> ↵ <meta name="viewport" content="widt
<!DOCTYPE html>是HTML文档类型声明,它告诉浏览器正在使用哪个HTML版本来解析文档。在HTML5中,<!DOCTYPE html>是唯一的文档类型声明,它告诉浏览器使用HTML5规范来解析文档。在HTML文档中,<!DOCTYPE html>应该作为第一行。
下面是一个简单的HTML文档示例,其中包含了<!DOCTYPE html>声明:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>My HTML Document</title>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is my first HTML document.</p>
</body>
</html>
```