html - 将子内容定位在父容器之外

标签 html css semantic-markup

我试图在视觉上将 DIV(文章标题)定位在其父 DIV(文章)容器之外。这可能吗?

enter image description here

我的标记示例在此处可用 - http://codepen.io/calebo/pen/CGoyD

最佳答案

试试这个:

.main {
  background: tomato;
  float: left;
  width: 600px;
  margin-top: 30px;        /* above Layout adjustment */
  /* removed overflow: hidden; */
  /* use always clearfix method instead */
}
.article_header {
  background: SteelBlue;
  color: #fff;
  position: absolute;
  bottom: 100%;
  margin-bottom: 10px;  /* to neutralize padding of parent container */
  left: -10px;          /* to neutralize padding of parent container */
  padding: 10px;        /* to neutralize padding of parent container */
  right: -330px;        /* to neutralize padding of parent container */
}
.main > article{
  position: relative;
}
.aside {
  background: cyan;
  float: right;
  width: 300px;
  margin-top: 30px;        /* above Layout adjustment */
}

Working Codepen

要进行调整,请使用 margin 属性。

关于html - 将子内容定位在父容器之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22705723/

相关文章:

html - IE11 - 如何在禁用的字段集中启用滚动条

html - 语义,标准以及使用 “lang”属性作为标记中的源代码

html - css 网格——我还需要使用列表吗?

javascript - 激活 jQuery UI Accordion 菜单中的当前内容部分

Javascript - `onload` 函数在加载之前调用?

jquery - 开设一门类(class),关闭其他类(class)

java - Seam/JSF 表单提交触发按钮 onclick 事件

html - vh 的最小高度与 body 的百分比?

html - Fieldset 元素的垂直对齐

html - 最常被误用的 html 标签有哪些?