【问题标题】:Flowing one floated Div around another Div of set height围绕另一个设定高度的 Div 流动一个浮动的 Div
【发布时间】:2014-09-25 17:14:50
【问题描述】:

假设我有两个 div,一个向左浮动,一个向右浮动,而右侧浮动 div 具有设定的高度。 如果高度增加到该点,我希望左侧浮动 div 内的内容填充右侧浮动 div 下方的空间。

我不确定这是否是正确的方法,如果有更好的方法,请告诉我。一些搜索让我有可能使用表(?),但我不确定。

.A {
  float:left; 
  height: 50%; 
}
.B {
  float:right;
  height:200px; 
  width:50%;
}
<div class = "A">
  Content of Unknown Height Will Go here
</div>
<div class = "B">
  Contact Information Box
</div>

到目前为止,我只有两个并排浮动的 div,而左侧 div 的内容向下延伸得更远。

【问题讨论】:

  • 请发布您的 HTML 和 CSS。

标签: html css alignment


【解决方案1】:

只是不要浮动左边的元素,把它放在右边浮动的元素之后:

#left {
  height: 200px;
  background: #B5E61D;
  border: 5px solid;
}
#right {
  float: right;
  background: #FF7F27;
  height: 100px;
  width: 100px;
  border: 5px solid;
}
<div id="right">Right floated div</div>
<div id="left">Left non-floated div</div>

【讨论】:

猜你喜欢
  • 2010-10-06
  • 2012-04-22
  • 1970-01-01
  • 2015-07-11
  • 1970-01-01
  • 2022-11-20
  • 1970-01-01
  • 1970-01-01
  • 2011-03-17
相关资源
最近更新 更多