html - 两个文本列和一个图像作为 div 的第三个

标签 html css

我在网页中通常有 3 个区域(标题和副标题、2 个文本列和左侧的测试以及右侧的图像)。我想得到以下结果:

enter image description here

不过我不知道怎么弄,我觉得跟wine image的z-index有关,但是怎么弄呢? 我有这个:

enter image description here

我当前的代码是:

<header>
    <div class="inner-header">
      <h1><a title="title">titlw</a></h1>
      <h2>subtitle</h2>
    </div>
  </header>
  <section id="tagline">
    <div id="tagline-content">column 1 and its text.</div>
    <div id="tagline-content-middle">column 2 and its text.</div>
  </section>
  <section id="product">
     <article class="product">
      <img src="http://hmimexico.com/noir.png" alt="Girl" />
      <h3>title</h3>
      <p>Lorem Ipsum .</p>

    </article>
  </section>

CSS:

header {
  margin-top: -40px;
  height: 165px;
}

header .inner-header {
  height:165px;
  text-align:center;
}

header h1{
  padding-top: 45px;
  text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
  margin-bottom:0;
}



header h2 {
  color:#111111;
  font-size: 19px;
  line-height: 22px;
  font-weight: bold;
  letter-spacing: 1px;
  margin-top:-2px;
  text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.15);
  text-transform:uppercase
}

#tagline {
  padding: 10px 0 10px 0;
  background:#111 ;
  text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.25);
}

#close-open-top {
  margin: -9px auto;
  text-align: center;
  width: 50px;
}

#close-open-top a {
  width:100px
}

#close-open-top:hover {
  margin-top:-11px;
  padding-bottom:2px
}

#tagline-content {
  color: #FFFFFF;
  text-align:left;  
  font-size: 10px;
  font-weight: normal;
  letter-spacing: 1px;
  line-height: 100px;
  text-transform: uppercase;
}

#tagline-content-middle {
  color: #FFFFFF;
  text-align:center;  
  font-size: 10px;
  font-weight: normal;
  letter-spacing: 1px;
  line-height: 100px;
  text-transform: uppercase;
}


#product {
  text-align:center;
  margin:16px auto;
  padding-top:10px;
  width:960px;
}

#product img {
  float: right;
  margin-left: 15px;
}

.product {
  width:100%;
  display:block;
  margin:0;
  text-align:left;
}

.product p {
  color: #4F4F4F;
  font-size: 16px;
  line-height: 21px;
  margin-bottom:38px
}

请看一下 fiddle : http://jsfiddle.net/2aEGp/1/

如何得到如图 1 所示的结果?

最佳答案

我相信这就是您要找的 ( jsFiddle )。我使用了以下组合:

  • width:33.3%float:left 在您的列上。我将前 2 设置为 33.3%,即使没有第三列,但产品图片代替了第三列。
  • overflow:hidden 在列容器上,因为列现在是 float 的,我们需要在其上设置 overflow 包装 #tagline div。
  • 产品图像上的负 margin-top,使其位于列包装器之上。无需添加 z-index

您也可以view the jsFiddle fullscreen看看它在浏览器窗口中的样子。

关于html - 两个文本列和一个图像作为 div 的第三个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18949170/

相关文章:

html - 是否可以对印度字符的不同部分应用不同的颜色?

javascript - 猫头鹰 slider 在响应式移动模式下显示三个元素而不是一个

php - 垂直旋转文本的浏览器回退

html - 并排对齐 P 标签中的文本,同时保持 Break-Word

javascript - 在 ng-include 中传递参数

php - file_get_contents(https ://. ..@me) : failed to open stream: HTTP request failed! HTTP/1.1 401 未经授权

html - 如何让横尺不伸过来?

javascript - AngularJS ng-style转义变量中的非法字符

html - div标签中的不同背景颜色

html - css:最大宽度不起作用