写个表白网页Html源码
<!DOCTYPE html>
<html>
<head>
<title>表白网页</title>
<style>
body {
background-color: pink;
font-family: Arial, sans-serif;
}
<pre><code> h1 {
text-align: center;
color: white;
}
p {
text-align: center;
color: white;
font-size: 20px;
}
.input-box {
text-align: center;
margin-top: 20px;
}
.input-box input[type="text"] {
width: 300px;
height: 30px;
font-size: 16px;
padding: 5px;
border-radius: 5px;
border: none;
outline: none;
}
.input-box input[type="submit"] {
width: 100px;
height: 40px;
font-size: 16px;
background-color: white;
color: pink;
border-radius: 5px;
border: none;
outline: none;
cursor: pointer;
}
.message {
text-align: center;
margin-top: 20px;
}
.message p {
font-size: 24px;
}
</style>
</code></pre>
</head>
<body>
<h1>表白网页</h1>
<p>亲爱的,你愿意接受我的表白吗?</p>
<div class="input-box">
<form>
<input type="text" placeholder="请输入你的名字">
<input type="submit" value="确定">
</form>
</div>
<div class="message">
<p></p>
</div>
<script>
const form = document.querySelector('form');
const input = document.querySelector('input[type="text"]');
const message = document.querySelector('.message p');
<pre><code> form.addEventListener('submit', function(e) {
e.preventDefault();
const name = input.value;
message.innerHTML = `亲爱的${name},我爱你!`;
});
</script>
</code></pre>
</body>
</html
原文地址: https://www.cveoy.top/t/topic/ieNy 著作权归作者所有。请勿转载和采集!