我曾多次使用float:右(或左)将图像和嵌入框浮动在容器顶部。现在,我需要浮动一个div到另一个div的右下角与正常的文本包装,你得到的浮动(文本包装上面和左边只有)。

我认为这一定是相对容易的,即使浮动没有底部值,但我还没有能够做到这一点使用一些技术和搜索网络还没有出现任何其他使用绝对定位,但这并没有给出正确的换行行为。

我原以为这是一种很常见的设计,但显然不是。如果没有人有建议,我将不得不把我的文本分解成单独的盒子,并手动对齐div,但这是相当不稳定的,我不想在每个需要它的页面上都这样做。


当前回答

这将在页面底部放置一个固定的div,并在向下滚动时修复到页面底部

#div {
    left: 0;
    position: fixed;
    text-align: center;
    bottom: 0;
    width: 100%;
}

其他回答

我只需要做一个表格。

<div class="elastic">
  <div class="elastic_col valign-bottom">
    bottom-aligned content.
  </div>
</div>

而CSS:

.elastic {
  display: table;
}
.elastic_col {
  display: table-cell;
}
.valign-bottom {
  vertical-align: bottom;
}

看看它的实际应用: http://jsfiddle.net/mLphM/1/

以下是我的解决方案:

<style>
.sidebar-left{float:left;width:200px}
.content-right{float:right;width:700px}

.footer{clear:both;position:relative;height:1px;width:900px}
.bottom-element{position:absolute;top:-200px;left:0;height:200px;}

</style>

<div class="sidebar-left"> <p>content...</p></div>
<div class="content-right"> <p>content content content content...</p></div>

<div class="footer">
    <div class="bottom-element">bottom-element-in-sidebar</div>
</div>

如果你将父元素设置为position:relative,你可以将子元素设置为底部设置位置:absolute;和底部:0;

#{外 宽度:10 em; 高度:10 em; 背景颜色:蓝色; 位置:相对; } #{内部 位置:绝对的; 底部:0; 背景颜色:白色; } < div id = "外" > < div id = "内部" > <标题> < / h1 >完成 < / div > < / div >

以下是正确的解决方案:

.toBottomRight
{
  display:inline-block;
  position:fixed;
  left:100%;
  top:100%;
  transform: translate(-100%, -100%);
  white-space:nowrap;
  background:red;
}

<div class="toBottomRight">Bottom-Right</div>

jsfiddle: https://jsfiddle.net/NickU/2k85qzxv/9/

如果你想要文本包装漂亮:-

.outer { 显示:表; } 在{ 身高:200 px; 显示:表格单元; vertical-align:底部; } /*仅用于样式*/ 在{ 背景:# eee; 填充:0 20px; } <!——需要两个父元素——> < div class = "外" > < div class = "内部" > < h3 >标题< / h3 > 示例看< p > < / p > < / div > < / div >