html - 外部容器(围绕 div 元素的图像)

标签 html css twitter-bootstrap image frontend

Block images surrounding div

我需要创建一种图像的“外部”容器来围绕包含文本的 div。请查看所附图片,大致了解我要实现的目标。我试过使用带有 Bootstrap 的列,但我无法创建图像重叠效果(在右侧)。

<!-- Top Layer -->
<div class="col-md-12"><img src="image1.png"></div>

<!-- Left Layer -->
<div class="col-md-3"><img src="image2.png"></div>

<!-- Text (Middle) -->
<div class="col-md-6"><p>This is the text This is the text</p></div>

<!-- Right Layer -->
<div class="col-md-3"><img src="image3.png"></div>

但这显然会导致右侧的长图像出现问题。 有什么想法可以用 CSS 完成吗?

如有任何帮助,我们将不胜感激。谢谢

最佳答案

我会把它分成 3 列,尽管您没有描述您希望它在较小的屏幕上看起来如何,因为列会按顺序折叠。以下代码段是您可以执行的操作的粗略示例。

.padded {
  padding: 1px;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Left Column -->
<div class="center-block" style="width: 80%">
  <div class="row">
    <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
      <div class="row">
        <img src="http://via.placeholder.com/100x100" class="padded" />
      </div>
      <div class="row">
        <img src="http://via.placeholder.com/100x100" class="padded" />
      </div>
      <div class="row">
        <img src="http://via.placeholder.com/100x100" class="padded" />
      </div>
    </div>

    <!-- Text (Middle) -->
    <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
        <div class="text-center">
          <img src="http://via.placeholder.com/200x100" class="padded" />
        </div>
        <div class="panel">
          This is the text This is the text
        </div>
    </div>

    <!-- Right Column -->
    <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
      <div class="row">
        <img src="http://via.placeholder.com/100x200" class="padded" />
      </div>
      <div class="row">
        <img src="http://via.placeholder.com/100x100" class="padded" />
      </div>
    </div>
  </div>
</div>

关于html - 外部容器(围绕 div 元素的图像),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45691163/

相关文章:

javascript - 禁止禁用 Javascript 的用户浏览 Web 应用程序

html - 图片形式提交IE

twitter-bootstrap - Bootstrap 表单输入字段和按钮不可点击

css - 文本居中,图像在左右两侧

javascript - 提交时不运行验证脚本

html - Flexbox:Div 并排放置而不是在下方

asp.net - 跨多种分辨率使 Logo 居中

jquery - 使用 CSS 将表格样式设置为井字棋盘

html - 是否可以使用 CSS 媒体查询来隐藏输入框但在打印时显示它们的值?

php - 不将 Bootstrap 日期值保存到 Laravel 中的数据库表中