我正在尝试学习自适应网站的引导程序基础知识。当我将元素放入“行”类中时,这些元素没有任何边距或填充,也没有可用空间,但是使用jumbotron和navbar这样的元素,则似乎存在填充,我无法摆脱它的左侧和右边。 任何帮助将不胜感激。
<nav class="navbar navbar-expand-lg navbar-expand-md">
<a class="navbar-brand" href="#">lorem ipsum</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="#">home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">about</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">contact</a>
</li>
</ul>
</div>
</nav>
<div class="jumbotron jumbotron-fluid" style="background-image:url(images/hero-image.jpg)">
<div class="container-fluid">
<h1 class="display-4">lorem ipsum</h1>
<p class="lead">lorem ipsum</p>
</div>
</div>
<div class="row newsletter">
<p class="col-lg-6 col-md-6 col-sm-6 col-xs-12">subscribe to our newsletter</p>
<form class="col-lg-6 col-md-6 col-sm-6 col-xs-12 newsForm">
<input type="email" placeholder="enter your email..." class="box">
<button type="submit" class="button">></button>
</form>
</div>
答案 0 :(得分:0)
Boostrap默认情况下在导航栏上应用填充,您只需执行以下操作即可删除左右填充:
String s = "Half Bone-in Spiral int with dark Packd Smithfield Half Bone-in Spiral Ham with Glaze Pack";
String[] res = splitIncludeDelimeter("(\\b.{1,32}(?![\\w-])\\W?)", s);
System.out.println(Arrays.toString(res));
// => [Half Bone-in Spiral int with , dark Packd Smithfield Half , Bone-in Spiral Ham with Glaze , Pack, ]
在.navbar.custom-navbar {
padding-left: 0rem !important;
padding-right: 0rem !important;
}
元素上应用custom-navbar
类。
要删除jumbotron的左右填充,请删除jumbotron内部的<nav>
:
<div class="container-fluid">
也可以从页面上移除水平滚动,将 <div class="jumbotron jumbotron-fluid" style="background-image:url(images/hero-image.jpg)">
<h1 class="display-4">odtom.com</h1>
<p class="lead">a site showcasing everything odt.</p>
</div>
放在row
内。
conatiner-fluid
答案 1 :(得分:0)
我不确定这是否可以回答您的问题,但是jumbotron元素中的左侧和右侧填充来自“ .container-fluid”类。看来您的目标容器是“ .jumbotron-fluid”类,该类当前设置为padding-left,right设置为0px。
仅在需要该类时将其定位为删除或修改填充。
.container-fluid {
width: 100%;
padding-right: 15px;
padding-left: 15px;
margin-right: auto;
margin-left: auto;
}