帮我用html,css,js做一个表白网页
时间: 2023-12-22 22:05:33 浏览: 24
好的,以下是一个简单的表白网页的HTML、CSS和JS代码:
HTML代码:
```
<!DOCTYPE html>
<html>
<head>
<title>表白页面</title>
<meta charset="UTF-8">
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>我要对你说</h1>
<p>亲爱的,我喜欢你已经有很久了,一直都没有勇气告诉你。</p>
<p>今天,我决定向你表白!</p>
<button id="love-btn">点击查看表白</button>
<div id="love-message"></div>
</div>
<script src="script.js"></script>
</body>
</html>
```
CSS代码:
```
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
margin: 50px auto;
padding: 20px;
background-color: #fff;
box-shadow: 0px 0px 10px rgba(0,0,0,0.2);
text-align: center;
}
h1 {
font-size: 36px;
margin-bottom: 20px;
}
p {
font-size: 20px;
margin-bottom: 10px;
}
#love-btn {
font-size: 24px;
padding: 10px 20px;
background-color: #FF69B4;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
#love-message {
font-size: 24px;
margin-top: 20px;
display: none;
}
```
JS代码:
```
const loveBtn = document.getElementById('love-btn');
const loveMessage = document.getElementById('love-message');
loveBtn.addEventListener('click', function() {
loveMessage.innerHTML = '我喜欢你!';
loveMessage.style.display = 'block';
});
```
以上代码会生成一个简单的表白网页,点击“点击查看表白”按钮后,会显示“我喜欢你!”的表白信息。你可以根据需要进行调整和修改。