刚开始使用Bootstrap。我想要一个与w3学校网站上的表格一致的表格:http://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_form_basic&stacked=h
然而,我没有排队。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>foo View</h2>
<form>
<div class="form-group">
<label for="fooName">Name:</label>
<input class="form-group" id="fooName" type="text" value="fbdshfjdhk"/>
</div>
<div class="form-group">
<label for="fooghk">ghk:</label>
<input class="form-group" id="fooghk" type="text" value="fdsfdsfds"/>
</div>
<div class="form-group">
<label for="fooXyz">Xyz:</label>
<input class="form-group" id="fooXyz" type="text" value="ffdhfjhdsjk"/>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</body
</html>
答案 0 :(得分:4)
您的表单输入标记应该具有“form-control”类而不是“form-group”。纠正后效果很好。 这是工作示例 -
<html>
<head>
<meta charset="UTF-8">
<title>Secure Login: Protected Page</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Product View</h2>
<form>
<div class="form-group">
<label for="productName">Name:</label>
<input class="form-control" id="productName" type="text" value="fbdshfjdh">
</div>
<div class="form-group">
<label for="productDescription">Description:</label>
<input class="form-control" id="productDescription" type="text" value="fdsfdsfds"/>
</div>
<div class="form-group">
<label for="productPrice">Price:</label>
<input class="form-control" id="productPrice" type="text" value="ffdhfjhdsjk"/>
</div>
<button type="submit" class="form-control btn btn-default">Submit</button>
</form>
</div>
</body>
</html>
答案 1 :(得分:0)
你应该正确学习网格系统,以便正确格式化表格。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Vertical (basic) Form</h2>
<form>
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email">
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password">
</div>
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
</div>
</body>
</html>