Bootstrap 的输入框无响应且无法更改其宽度
Input boxes of Bootstrap are not responsive and cannot change their width
我是 bootstrap 的新手,目前正在开发一个简单的页面。到目前为止,我完成了以下代码,但我遇到了一些问题。第一个问题是输入框的宽度,我需要它们更宽一点但做不到。他们也没有反应。另一个问题是徽标,它总是位于横幅的左侧,但当 window 宽度太小时,它会出现在 window 的右侧,而不是横幅的左侧。
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script
src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<style>
.form-control {
-webkit-border-radius: 5;
-moz-border-radius: 5;
border-radius: 5;
}
</style>
</head>
<body>
<div id="header" class="container-fluid">
<div class="row" style="background-color: green;">
<div class="col-md-3">
<div id="logo" style="margin-right: 0px; float: right;">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="40px" height="40px" />
</div>
</div>
<div class="col-md-6">
<div id="banner">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR-32Ge8DaAq_81IBLPFdRWmKVYgvN9YyDKKjXh6CTTpgey8qbC"
height="40px;" width="300px;" />
</div>
<fieldset>
<form class="form-inline" role="form" method="post"
action="employee/search.htm" name="employeeForm" id="employeeForm">
<div class="form">
<div class="col-lg-3">
<input class="form-control input-sm" type="text"
name="firstName" id="fistName" placeholder="First Name">
</div>
<div class="col-lg-2">
<input class="form-control input-sm" type="text" name="lastName"
id="lastName" placeholder="Last Name">
</div>
<button type="submit" class="btn btn-success">Search</button>
<a href="#" class="btn btn-info btn-sm">Click1</a> <a href="#"
class="btn btn-info btn-sm">Click2</a>
</form>
</fieldset>
</div>
<div class="col-md-3">
<div id="images" style="float: left;">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" /> <img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" /> <img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" /> <img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" />
</div>
</div>
</div>
<div id="content" class="container">...</div>
</body>
</html>
输入字段:bootstrap page 上有一个大警告框,内联字段可能需要自定义宽度。所以你必须自己处理宽度。
徽标:由于您已应用 float: right;
,徽标始终位于相关容器的右侧。在桌面模式下,它看起来像在左侧,因为它在浮动列中。在移动模式下,不再有列浮动。您可以使用媒体查询通过 CSS 设置徽标浮动,这样您就可以处理 right/non-floating 行为。
我是 bootstrap 的新手,目前正在开发一个简单的页面。到目前为止,我完成了以下代码,但我遇到了一些问题。第一个问题是输入框的宽度,我需要它们更宽一点但做不到。他们也没有反应。另一个问题是徽标,它总是位于横幅的左侧,但当 window 宽度太小时,它会出现在 window 的右侧,而不是横幅的左侧。
代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet"
href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script
src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<style>
.form-control {
-webkit-border-radius: 5;
-moz-border-radius: 5;
border-radius: 5;
}
</style>
</head>
<body>
<div id="header" class="container-fluid">
<div class="row" style="background-color: green;">
<div class="col-md-3">
<div id="logo" style="margin-right: 0px; float: right;">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="40px" height="40px" />
</div>
</div>
<div class="col-md-6">
<div id="banner">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR-32Ge8DaAq_81IBLPFdRWmKVYgvN9YyDKKjXh6CTTpgey8qbC"
height="40px;" width="300px;" />
</div>
<fieldset>
<form class="form-inline" role="form" method="post"
action="employee/search.htm" name="employeeForm" id="employeeForm">
<div class="form">
<div class="col-lg-3">
<input class="form-control input-sm" type="text"
name="firstName" id="fistName" placeholder="First Name">
</div>
<div class="col-lg-2">
<input class="form-control input-sm" type="text" name="lastName"
id="lastName" placeholder="Last Name">
</div>
<button type="submit" class="btn btn-success">Search</button>
<a href="#" class="btn btn-info btn-sm">Click1</a> <a href="#"
class="btn btn-info btn-sm">Click2</a>
</form>
</fieldset>
</div>
<div class="col-md-3">
<div id="images" style="float: left;">
<img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" /> <img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" /> <img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" /> <img
src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR_FCNfsR_UhKGdOTtUKK8XfQXKnlgw5Q0jaBbdiCSBTnCoaGgqIA"
width="20px" height="20px" />
</div>
</div>
</div>
<div id="content" class="container">...</div>
</body>
</html>
输入字段:bootstrap page 上有一个大警告框,内联字段可能需要自定义宽度。所以你必须自己处理宽度。
徽标:由于您已应用 float: right;
,徽标始终位于相关容器的右侧。在桌面模式下,它看起来像在左侧,因为它在浮动列中。在移动模式下,不再有列浮动。您可以使用媒体查询通过 CSS 设置徽标浮动,这样您就可以处理 right/non-floating 行为。