html - 背景大小 : cover is not working to completely fill div with background-image

标签 html css

我希望背景图像填充包含它的 div。我将附上图片以显示正在发生的事情。

这个空白的原因是什么?它阻止我将容器移近。

这是代码笔链接:http://codepen.io/ManBearPigg/full/qZVJWy/

#firstContainer {
  background-image: url("/focusbackground.png");
  background-size: cover;
  width: 720px;
  height: 700px;
  float: left;
  margin-left: -7%;
}

#secondContainer {
  background-image: url("/focusbackground.png");
  background-size: cover;
  width: 720px;
  height: 700px;
  float:right;
  margin-right: 5%;
}

这是html

<div id="container">
  <div id="firstContainer">
    <form id="firstForm" action="">
      <textarea id="firstArea" type="text" onkeypress="return myKeyPress(event)"></textarea>
      <input type="submit" id="firstSubmit"></input>
      <div id="lineNo"></div>
    </form>
  </div>
  <div id="secondContainer">
    <form id="secondForm" action="">
      <textarea id="secondArea" type="text" onkeypress="return mySecondKeyPress(event)"></textarea>
      <input type="submit" id="secondSubmit"></input>
    </form>
  </div>
</div>

最佳答案

也许这更像是评论而不是答案,但我无法在您的帖子上添加评论,所以如果我不明白您的问题,我深表歉意。

我能看到的是你的image本身有一个白色的边框。您可能需要剪切图像以删除没有图片的部分。通过这样做,它将覆盖 div

关于html - 背景大小 : cover is not working to completely fill div with background-image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36440030/

相关文章:

javascript:html5 模式正则表达式问题

css - 背景仅覆盖移动页面的一半

javascript - 如何将自动高度设置为 svg 元素?

html - 为什么这段代码在 iPhone 上加载时右侧有一个空格?

html - CSS - 保持图像纵横比 flexbox

javascript - JS - 为什么在正常流程中 div 之间有空间

jquery - 使用 jquery 更改 css 文件不起作用

javascript - 将页面标题保存在变量中,以便在发布后可以访问

html - 水平显示菜单项

html - 如何使用 laravel collective 5.2 以形式实现 css 类。 *