EDIT 5/21/13 13:40 EST :inline-block
スタイルを追加しました。
次のページを検討してください。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
form { display: inline-block; }
</style>
<title>Log in </title>
</head>
<body>
<form action="/login" method="post">
<label for="username">Username: </label><input type="text" name="username" id="username">
<label for="password">Password: </label><input type="password" name="password" id="password">
<input type="submit" value="Log in">
</form>
</body>
</html>
CSSでフォームを中央に配置する方法はありますか
- ブートストラップ グリッドに div を追加する
- パーセンテージまたはピクセルでフォームの幅を推測する
- フォーム内のテキストを中央揃えにする
基本的に、フォームを含むブロックの幅はその内容によって自動的に決定され、そのブロックの中心がページの中心に整列するようにします。