我是Bootstrap网站设计的新手,我刚刚在这里做了一个简单的开始,看起来不错,但需要进行一些调整才能更加统一和漂亮。
正如你在这里看到的,我使用过的Jumbotron看起来相当集中,但它下面的Well和Search Bar却没有。我想要一些帮助,以便我能更好地融合在一起:))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="css/bootstrap.css">
</head>
<body>
<div class="header-container">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="jumbotron" style="width: 100%">
<h1>Cool Text</h1>
<p>Catchphrase</p>
</div>
</div>
</div>
</div>
</div>
<div class="search-bar-container">
<div class="well">
<div class="container">
<div class="row">
<div class="col-lg-12">
<form class="navbar-form" role="search">
<div class="input-group" style="width: 100%">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
答案 0 :(得分:3)
您正在使用class="navbar-form"
这意味着在导航栏中使用,这就是为什么它不会占据其所在div的100%。
根据您是否在这些容器中执行任何其他操作,您目前不需要使用任何列或行。我还为你的jumbotron增加了一些填充物,不到768px,因为你&#39;&#39;看到文本浮动到div的边缘,否则。
请参阅示例代码段。
@media (max-width: 767px) {
.jumbotron.jumbotronic {
padding-left: 20px;
padding-right: 20px;
}
}
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<div class="well well-sm">
<h3>Without Col/Row</h3>
</div>
<div class="header-container">
<div class="container">
<div class="jumbotron jumbotronic">
<h1>Cool Text</h1>
<p>Catchphrase</p>
</div>
</div>
</div>
<div class="search-bar-container">
<div class="container">
<div class="well">
<form role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
<hr>
<div class="well well-sm">
<h3>With Col/Row</h3>
</div>
<div class="header-container">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="jumbotron jumbotronic">
<h1>Cool Text</h1>
<p>Catchphrase</p>
</div>
</div>
</div>
</div>
</div>
<div class="search-bar-container">
<div class="container">
<div class="row">
<div class="col-lg-12">
<div class="well">
<form role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span>
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
&#13;
答案 1 :(得分:0)
像这样的东西,容器有一些预定义的宽度和边距:
<div class="header-container">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="jumbotron" style="width: 100%">
<h1>Cool Text</h1>
<p>Catchphrase</p>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<div class="search-bar-container">
<div class="well">
<div class="row">
<div class="col-lg-12">
<form class="navbar-form" role="search">
<div class="input-group" style="width: 100%">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
答案 2 :(得分:0)
试试这个。
@media screen and (max-width: 768px) {
.container .jumbotron, .container-fluid .jumbotron {
padding-right: 19px;
padding-left: 19px;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<div class="container header-container">
<div class="jumbotron">
<h1>Cool Text</h1>
<p>Catchphrase</p>
</div>
<form class="search-bar-container well" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</form>
</div>
</body>
</html>