Html 在 div 内浮动一个跨度右下角
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10822421/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Float a span bottom right inside a div
提问by user823527
Possible Duplicate:
How do I get a div to float to the bottom of its container?
可能的重复:
如何让 div 浮动到其容器的底部?
I have this code to float a div to the bottom right side of a div. But the span gets stuck to the upper left.
我有这段代码可以将 div 浮动到 div 的右下角。但是跨度卡在左上角。
<div id="color_tile" class="select_tile" title="Choose color" style="background: grey; background-image: url(wallpaper/201_color_picker.jpg);" >
<span id="color_picker" style="visibility: visible; display: block; float: right; vertical-align: bottom;"></span>
</div>
Is there a different way to place the span?
有没有不同的方式来放置跨度?
回答by sg3s
You should probably separate your HTML/CSS from each other properly.
您可能应该正确地将您的 HTML/CSS 彼此分开。
Your code could look something like this
您的代码可能如下所示
HTML:
HTML:
<div>
<span>Absolute right bottom aligned to div...</span>
</div>
CSS:
CSS:
div { position: relative; }
div > span { position: absolute; right: 0; bottom: 0; }
Obviously your div should have some height/width which exceeds that of the span, but generally this is a very acceptable way of doing it.
显然你的 div 应该有一些超过跨度的高度/宽度,但通常这是一种非常可接受的方式。
This doesn't make the content of the div 'flow' around the span but that wasn't specified clearly. As said, what you have there should work in that case and if it doesn't it is in the rest of your code.
这不会使 div 的内容围绕跨度“流动”,但这并未明确指定。如上所述,你在那里应该有什么在这种情况下工作,如果没有,它在你的代码的其余部分。
回答by locrizak
vartical-align is very particular to get to work (which is why I almost never use it)
vartical-align 非常适合开始工作(这就是为什么我几乎从不使用它)
On the span:
position:absolute; bottom:0; right:0;
在跨度上:
position:absolute; bottom:0; right:0;
and put a height/width on the parent div and you'll be all set
并在父 div 上放置一个高度/宽度,您将全部设置好