我正在使用Bootstrap v3.3.1创建一个简单的网页。在尝试将
form-inline
强制转换为移动视图中的内联表单时,遇到了困难。它没有像我想象的那样变成内联表单。
如何让form-inline
在移动视图下也起作用?
我的代码:
index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Hello World</title>
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/style.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Arvo' rel='stylesheet' type='text/css'>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<!-- Page Content -->
<div class="container full">
<div class="row">
<div class="col-md-12">
<h1 class="text-center hero">Mauris risus nisi, hendrerit id orci non, tempor hendrerit enim</h1>
</div>
</div>
<!-- /.row -->
</div>
<!-- /.container -->
<div class="container dropdown-section">
<div class="row">
<div class="col-md-6 col-md-offset-3 dropdown-wrapper">
<form class="form-inline">
<div class="form-group">
<input type="email" class="form-control input-lg date-input" id="exampleInputEmail2" placeholder="Date">
</div>
<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Moving from <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a>
</li>
<li><a href="#">Another action</a>
</li>
<li><a href="#">Something else here</a>
</li>
<li class="divider"></li>
<li><a href="#">Separated link</a>
</li>
</ul>
</div>
<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-default btn-lg dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
Moving to <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a>
</li>
<li><a href="#">Another action</a>
</li>
<li><a href="#">Something else here</a>
</li>
<li class="divider"></li>
<li><a href="#">Separated link</a>
</li>
</ul>
</div>
<button class="btn btn-primary btn-lg" type="submit">Search</button>
</form>
</div><!-- /col-md-6 col-md-offset-3 dropdown-wrapper -->
</div><!-- /.row -->
</div><!-- /.container -->
<!-- jQuery -->
<script src="js/jquery.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
style.css:
body {
background: none;
}
.full {
background: url(http://i.imgur.com/BwqePti.jpg) no-repeat center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
min-height: 400px;
width: 100%;
z-index: 1;
}
.text-center {
text-align: center;
}
h1.hero {
margin-top: 170px;
color: #ffffff;
text-shadow: 2px 2px 2px rgba(150, 150, 150, 0.8);
font-family: 'Arvo', serif;
font-size: 30px;
}
.dropdown-section{
width: 100%;
background-color: #000000;
}
.dropdown-wrapper{
margin-top: 20px;
margin-bottom: 20px;
}
.date-input{
width: 220px !important;
}
桌面视图:
移动端视图: