[英]Align position absolute element content to bottom with only one element
I have a position absolute div element with text content inside without any tag, like this:我有一个位置绝对 div 元素,里面有文本内容,没有任何标签,如下所示:
<div class="element">
This is some content...
</div>
.element{
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
overflow: hidden;
padding: 10px;
color: white;
}
I want to align that content to the bottom of the div, but without using more html tags(like this answer on a similiar question ), to keep it simple.我想将该内容与 div 的底部对齐,但不使用更多的 html 标签(就像这个关于类似问题的答案),以保持简单。
How can I achieve this using css only?如何仅使用 css 实现此目的?
You can achieve that with CSS flexbox like this:你可以像这样使用 CSS flexbox来实现:
.element { position: absolute; top: 10px; left: 10px; right: 10px; bottom: 10px; overflow: hidden; padding: 10px; color: red; background: green; display: flex; align-items: flex-end; }
<div class="element"> This is some content... </div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.