<h3> </h3> <h4>和<p>标签之间的空格

时间:2018-01-16 23:19:52

标签: html css twitter-bootstrap-3

我的代码很简单,虽然我仍然无法弄清楚如何去除每个标签之间的白色间隙。你可以在h3和h4标签之间用背景颜色看到它。我如何摆脱这个空间?

.realEstatePricing h3 {
  Background: lightblue;
  height: 40px;
}

.realEstatePricing h4 {
  Background: lightgrey;
}
<section class="realEstatePricing">
  <div class="container">
    <div class="row">
      <div class="col-sm-4">
        <h3 class="text-center">Photo Package</h3>
        <h4 class="text-center">$99</h4>
        <p>description 1</p>
        <p>description 1</p>
        <p>description 1</p>
        <p>description 1</p>
      </div>
    </div>
  </div>
</section>

2 个答案:

答案 0 :(得分:1)

您可以通过为两者添加保证金为0来实现

&#13;
&#13;
 .realEstatePricing h3 {
   Background: lightblue;
   height: 40px;
   margin:0;
  }
 .realEstatePricing h4 {
   Background: lightgrey;
   margin:0;
  }
&#13;
<html>
<head>
</head>
<body>

    <section class="realEstatePricing">
        <div class="container">
            <div class="row">
                <div class="col-sm-4">
                    <h3 class="text-center">Photo Package</h3>
                    <h4 class="text-center">$99</h4>
                    <p>description 1</p>
                    <p>description 1</p>
                    <p>description 1</p>
                    <p>description 1</p>
                </div>
            </div>
        </div>
   </section>
</body>
</html>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

作为对其他答案的回答,您可以这样做:

.realEstatePricing h3 {
    background-color: lightblue;
    height: 40px;
    margin-bottom: 0;
}
.realEstatePricing h4 {
    background-color: lightgrey;
    margin-top: 0;
}

这样,您的左边距和上边距将保持当前状态。