Open1
Formの基本
<ul>
を使うパターン
index.html
<!DOCTYPE html>
<html lang="ja-Jp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Basic Form</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form action="/app.js" method="post">
<ul>
<li>
<label for="name">名前:</label>
<input type="text" id="name" name="user_name">
</li>
<li>
<label for="email">メールアドレス:</label>
<input type="email" id="email" name="user_email">
</li>
<li>
<label for="message">メッセージ:</label>
<textarea id="message" name="user_message"></textarea>
</li>
<li class="button">
<button type="submit">送信</button>
</li>
</ul>
</form>
</body>
</html>
style.css
body {
display: grid;
place-items: center;
height: 95vh;
}
form {
padding: 1em;
border: 1px solid #999;
}
ul {
display: grid;
place-items: center;
gap: 1em 0;
list-style: none;
padding: 0;
margin: 0;
font-size: 1em;
}
li {
display: flex;
}
label {
width: 130px;
text-align: right;
margin-right: 0.5em;
}
input,
textarea {
width: 300px;
border: 1px solid #999;
box-sizing: border-box;
font: 1em sans-serif;
}
textarea {
height: 70px;
}
.button {
padding-right: 117px;
}