CSS文本对齐容器的底部

编程入门 行业动态 更新时间:2024-10-27 22:26:47
本文介绍了CSS文本对齐容器的底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一张标题,一面有大图像,另一面有一小段文字。我希望段落在标题div的底部开始。如果段落中有5行,我希望最后一行位于标题的底部。

I have a header which has a large image floated on one side, and a small paragraph of text on the other side. I want the paragraph to start at the bottom of the header div. If there were 5 lines in the paragraph, I want the last line to be at the bottom of the header. I'm having trouble getting the paragraph to align itself down there.

我有这样的事情:

<div id='header'> <img id='logo' /> <p id='quote'></p> </div>

而CSS是:

And the CSS is:

div#header { height: 200px; } div#header img#logo { float: left; } p#quote { float: left; }

推荐答案

jsfiddle/danheberden/ymwPe/

<div id="container"> <div id="gonnaBeOnTheBottom"> <p>Hi there!</p> <p>I'm on the bottom!</p> </div> </div>

css:

#container { background: #EEE; height:400px; width:400px; position:relative; } #gonnaBeOnTheBottom { position:absolute; bottom:0; }

通过设置 position:relative 在父容器上,你可以在其中放置绝对位置元素:)

by setting position:relative on the parent container, you can absolute position elements inside of it :)

更多推荐

CSS文本对齐容器的底部

本文发布于:2023-10-08 09:56:32,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:容器   文本   CSS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!