gpt4 book ai didi

javascript - Bootstrap 表单未正确排列

转载 作者:行者123 更新时间:2023-11-28 14:59:08 24 4
gpt4 key购买 nike

刚刚开始使用 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>

最佳答案

您的表单输入标记应具有“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>

关于javascript - Bootstrap 表单未正确排列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41738153/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com