定位到动态 div 的底部
这就是我想要实现的目标
https://i.sstatic.net/e9xZa.jpg
我尝试了这个
jsfiddle.net/RUSm3/
但正如你所看到的,日期在图像上重叠。
所以我为日期
jsfiddle.net/9aw29/
添加了 left:215px它看起来不错,但也许我没有图像。如何让日期回到最左边?我试图在没有 php 的情况下实现这一目标。
This is what I'm trying to achieve
https://i.sstatic.net/e9xZa.jpg
I tried this
jsfiddle.net/RUSm3/
but as you can see the date overlaps on the image.
So I added left:215px for the date
jsfiddle.net/9aw29/
It looks good but perhaps I don't have an image. How can I get the date back to the far left? I'm trying to achieve this without php.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您有一个像这样的 div
和这个 css 片段,您的日期 div 将位于其容器的右下角。
您可以在此处验证其是否正常工作
If you have a div like this
with this css fragment your date div will be positioned to the bottom right of it's container.
You can verify it working here
我不确定您的标记是什么,但最简单的解决方案是将标题、文本和日期全部放在一个
div
中(在.entry
内),然后浮动左侧的图像(如果存在)。日期的位置将如您在示例中所做的那样。当没有图像时,整个div将向左平移。I'm not sure what your markup is, but the easiest solution would be to have the heading, text and date all in one
div
(inside.entry
), and float the image to the left if it's there. The date would be positioned as you have already done in your example. When there is no image, the entire div will move flush left.这是我的想法,可能对您来说是一个很好的起点。简而言之,将两个文本区域包装在它们自己的 div 中,并将它们包装在父 div 中。将父 div 向右浮动并使其位置不是静态的。如果位置是静态的,则不能将position:absolute属性与其子div一起使用。
Here is what I came up with and will probably be a good jumping-off point for you. In short, wrap the two text areas in their own divs, and wrap them in a parent div. Float the parent div to the right and make it's position something other than static. If the position is static, you cannot use the position: absolute attribute with it's children divs.