html - 两个宽度为 50% 的 div,内容在容器内

标签 html css twitter-bootstrap twitter-bootstrap-3

如何实现图片中的效果?

enter image description here

它只是用于列的常规 Bootstrap 代码,但前两列应该在 .container 中的白色 background 上,而另外两列在黑色 background 上 黑色的 background 一直到最后。

CodePen

<div class="container">
<div class="col-md-3">
  <p>First column</p>
  </div>
<div class="col-md-3">
  <p>Second column</p>
  </div>
<div class="col-md-3">
  <p>Third column</p>
  </div>
<div class="col-md-3">
  <p>Fourth column</p>
  </div>
</div>

最佳答案

使用linear-gradientbody , 给你 .container是 parent ,你不会有任何包装 .container

Sorry that I'm bothering you, but what I meant was to place the image like this image.prntscr.com/image/78940c8115c943a186500ac24556758b.jpeg

添加另一个父级 div (作为 body 的 child )并添加 background-image那个div

body {
  background: linear-gradient(to right, white 0%, white 50%, black 50%, black 50%, black 100%);
}
#wrap {
  background: url(//lorempixel.com/200/200) no-repeat  66.6% 0 / 25% auto
}
.container {
  border: 1px solid #f01;
}
[class^="col-"] p {
  color: white;
  height: 75px;
  background-color: blue
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div id="wrap">
  <div class="container">
    <div class="col-xs-3 col-md-3">
      <p>First column</p>
    </div>
    <div class="col-xs-3  col-md-3">
      <p>Second column</p>
    </div>
    <div class="col-xs-3 col-md-3">
      <p>Third column</p>
    </div>
    <div class="col-xs-3 col-md-3">
      <p>Fourth column</p>
    </div>
  </div>
</div>

关于html - 两个宽度为 50% 的 div,内容在容器内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38147445/

相关文章:

html - 为什么我的 td 高度似乎没有调整?

html - 对齐自定义复选框问题 css

javascript - Bootstrap 5 Popover 错误 - 找不到名称 'bootstrap'

html - Bootstrap : add margin/padding space between columns

jquery - 向左展开箭头元素

javascript - HTML 表单不使用 appendChild 提交

javascript - 我需要在浏览器中显示每个水果 a 和 b

html - CSS 样式表错误 - DOMException 无法在 css.stylesheet 上插入规则

javascript - 更改滚动长度

javascript - 使用 Bootstrap 删除所有屏幕尺寸大于 480 像素的 div