[英]Row having more white space at top and bottom
I am having problem with the bootstrap rows, where I am getting more white space at top and bottom of the rows, which I need to remove, I want the row to have just the height of the text present inside it... 我在引导程序行中遇到问题,在该行的顶部和底部有更多的空白空间,需要删除,我希望该行中的文本高度正确...
HTML is given below : HTML如下:
<div class="row">
<div class="col-sm-6 text-muted">
<p>Author</p>
</div>
<div class="col-sm-6 text-right font-bold">
<p>abcd</p>
</div>
</div>
<div class="row row-divider"></div>
<div class="row">
<div class="col-sm-6 text-muted">
<p>Date Created</p>
</div>
<div class="col-sm-6 text-right font-bold">
<p>Nov 28, 19:30</p>
</div>
</div>
<div class="row row-divider"></div>
<div class="row">
<div class="col-sm-6 text-muted">
<p>File Type</p>
</div>
<div class="col-sm-6 text-right font-bold">
<p>Microsoft Word</p>
</div>
</div>
<div class="row row-divider"></div>
<div class="row">
<div class="col-sm-6 text-muted">
<p>Last Modified</p>
</div>
<div class="col-sm-6 text-right font-bold">
<p>Dec 08, 11:00</p>
</div>
</div>
All you need to do is add the following CSS to your code: 您需要做的就是在代码中添加以下CSS:
.row-divider {
height: 1px;
margin: 0px;
overflow: hidden;
background-color: #e7eaec;
}
p {
margin: 0;
padding: 0;
line-height: 1;
}
You basically tell all your paragraphs to have 0 margins so the line height is equal to the text height. 您基本上告诉所有段落的页边距为0,因此行高等于文本高度。
On a different note, you might want to use text-muted
class on the <p>
tags instead of the whole <div>
that contains those <p>
tags. 另外,您可能希望在
<p>
标记上使用text-muted
类,而不是包含这些<p>
标记的整个<div>
。 Why? 为什么? because for example tomorrow you will add two more lines to that div that wouldn't need to be
text-muted
, you would need to define a new class to cancel those values. 因为例如,明天您将向该div添加另外两行,而无需对其进行
text-muted
,则需要定义一个新类来取消这些值。 Style the things you need and only those . 设计您需要的东西,只有那些 。
If you want the left text and right text on the same line in Jsfiddle just change the col-sm-x
class to col-xs-x
class, basically, jsfiddle view is a bit small and that's why you see two lines. 如果您想在Jsfiddle中的同一行上添加左文本和右文本,只需将
col-sm-x
类更改为col-xs-x
类,基本上,jsfiddle视图会很小,这就是为什么看到两行的原因。
You have to set: 您必须设置:
p{
margin: 0;
line-height: 14px; /*you can reduce this value to achieve what you want*/
}
Here a JSFiddle example to play with 这是一个JSFiddle示例
Note that .row-divider
has margin: 9px 0px
if you want you can reduce it to closer to the text above it. 请注意,
.row-divider
margin: 9px 0px
如果需要),可以将其缩小为更接近其上方的文本。
Check this out for more information about line-height
http://www.w3schools.com/cssref/pr_dim_line-height.asp 签出有关
line-height
更多信息http://www.w3schools.com/cssref/pr_dim_line-height.asp
p{
margin: 5px 0px;
}
.clearfix {
zoom: 1;
}
.clearfix:before, .clearfix:after {
content: "";
display: table;
line-height: 0;
}
.clearfix:after {
clear: both;
}
use clearfix class with row. 对行使用clearfix类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.