html - 尽管内容只有一行,但如何将标题固定为两行

标签 html css

如何在文本只有一行的情况下将链接标题固定为两行?

CodePen Link to Problem

当标题只有一行时,评论和点赞按钮的位置变得不一致,如图HERE .

我尝试使用 float 但无济于事。然后我尝试设置 div.info 相对的位置,并将我的评论和点赞按钮设为绝对,这样我就可以将它们从文档流中删除,但不知何故,评论和点赞按钮仍然存在遵循文档流程。

.info
    height: 20em
    position: relative

.comment
    position: absolute
    margin-top: -1.5em
    font-size: 1.2em
    float: left
    padding-left: 3em
    a
        text-decoration: none
        color: white
        &:visited
            color: white
            font-weight: 700
.like
    margin-top: -1.5em
    font-size: 1.2em
    position: absolute
    top: 0
    bottom: 20px
    right: 20px
    // float: right
    padding-right: 3em

最佳答案

您将按钮视为每个部分的页脚。 将两个按钮(评论和喜欢)放在同一个 div 中,并添加它:

position: absolute;
bottom: 0;

到 div 的类。

我的屏幕似乎比你的大:每个标题都在一行中,所以按钮总是亮着的。 更多,请注意:当我向下滚动页面时,滑动速度太快,所以我无法阅读您的最后一项。

关于html - 尽管内容只有一行,但如何将标题固定为两行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31249639/

相关文章:

javascript - 将 HTML 表格导出到 Excel 时的阿拉伯编码

javascript - 学习 JavaScript 是否有必要使用 HTML 5 的所有功能?

javascript - 如何在不更改页面哈希的情况下使用 javascript 导航到页面中的元素

javascript - 添加 "modal div"时更改背景颜色和透明度

javascript - 打印一个 Html 可滚动页面 : scrollable part not printed

javascript - Fabric JS : Set X Y Coordinates in Canvas Image | Set Position in Canvas Image

CSS 中网站的 ASP.NET 根文件夹

html - 悬停后保持元素被选中

HTML/CSS 将对象与 float 中心对齐

css - 以编程方式使用 .less 时如何输出错误?