将我的内部 div 放在右下角的最简单方法是什么?
<div style="width:200px; height:200px; border:3px #FF6666 solid">
<div style="font-weight:bold; text-align:right;">Krishna</div>
</div>
这是我的代码.. 谢谢大家
将我的内部 div 放在右下角的最简单方法是什么?
<div style="width:200px; height:200px; border:3px #FF6666 solid">
<div style="font-weight:bold; text-align:right;">Krishna</div>
</div>
这是我的代码.. 谢谢大家
试试这个,设置你的外部div
以position: relative;
确保div
内部在设置为 时会留在里面position: absolute;
。然后您可以通过设置将其指定为位于右下角bottom: 0; right: 0;
。
<div style="width:200px; height:200px; border:3px #FF6666 solid; position: relative">
<div style="font-weight:bold; text-align:right;position: absolute;bottom: 0; right: 0; ">Krishna</div>
</div>
根据 div 的父级,您可以将其绝对定位:
<div style="width:200px; height:200px; border:3px #FF6666 solid;position: relative;">
<div style="font-weight:bold; text-align:right;position: absolute; bottom:0; right:0">Krishna</div>
</div>
<div style="width:200px; height:200px; border:3px #FF6666 solid; position: relative">
<div style="font-weight:bold; position: absolute;bottom: 0; right: 0; ">Krishna</div>
</div>
用内部 div 修改了你的小提琴。还添加了水印。
在此处查看更新的代码:http: //jsfiddle.net/8Lu1vpbr/
#outerDiv
{
width: 200px;
height: 180px;
border:3px #F02020 solid;
position:relative;
}
#bottomRight
{
position: absolute;
right: 0px;
bottom: 0px;
}
.watermark
{
opacity: 0.5;
color: BLACK;
padding-right: 2px;
}
<div id="outerDiv">
<span> This is some content. <br />The bottom aligned item can be watermarked if needed.</span>
<div class='watermark' id="bottomRight">I am here!!!</div>
</div>
见这里:http: //jsfiddle.net/9MYFM/
您必须将 更改position
为absolute
。