img后div内的垂直间隙

时间:2015-01-19 05:14:59

标签: css

我无法弄清楚这个5px差距来自哪里。

图片中的白色间隙不是两个div之间的间隙,而是横幅div中的间隙。出于某种原因,它超出了图片的高度,任何想法为什么?

Screenshot

代码是:



#banner {
  width: 100%;
  margin-top: 20px;
  position: relative;
  text-align: center;
  overflow: auto;
}
#banner h2 {
  font-size: 300%;
  text-transform: uppercase;
  color: #fff;
  font-weight: normal;
  margin: 20px;
}
#banner img {
  width: 100%;
}
.banner-title {
  background-color: rgba(0, 0, 0, 0.7);
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
}
.banner-title h2 {
  padding: 0;
  margin: 0;
}
.banner-title p {
  color: #fff;
  margin-top: 0;
  font-size: 120%;
}
.progress-wrapper {
  background-color: #3084bf;
  height: 60px;
  padding: 10px 0;
}
.progress-bar {
  width: 50%;
  margin-left: 25%;
  height: 40px;
  line-height: 40px;
  text-align: center;
  font-size: 80%;
  padding: 10px 0;
}
.progress-bar-reached {
  background-color: #ffd105;
  height: 40px;
  float: left;
  text-align: center;
}
.progress-bar-remaining {
  background-color: #eaeaea;
  float: right;
}

<div id="banner">

  <img src="http://www.placehold.it/500">

  <div class="banner-title">

    <h2><span class="yellow-text">Pollinate</span> Water</h2>

    <p>A Pollinate Energy project aiming to spread new water filters to another 500 urban poor Indian families</p>

  </div>

</div>

<div class="progress-wrapper">

  <div class="progress-bar">

    <div class="progress-bar-reached" style="width:<?php echo $charityProgress3; ?>%">

      25 Families

    </div>

    <div class="progress-bar-remaining" style="width:<?php echo $charityRemaining3; ?>%">

      500 Families

    </div>

  </div>

</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

试试这个:

在你的css中添加这个

#banner img {
    display: block;
    width: 100%;
}