html - 使用 bootstrap 3 将 div 中的文本对齐到底部

标签 html css wordpress twitter-bootstrap-3

我想在使用 bootstrap 的 wordpress 站点中将标题与容器底部对齐,该怎么做?

我尝试使用正向和相对定位,但我得到的 txt 与所有左侧或最顶部对齐..

这是我的代码:

<div class="container-fluid pre-content-banner">
    <div class="container">
    <div class="intro-title bottom-aligned-text">
        <h1><?php the_title(); ?></h1>
    </div>  
    </div>
    </div> <!-- end container fluid -->

CSS:

.pre-content-banner {
    height: 300px;
    background: white url("images/businessppl-bg.jpg") no-repeat center;
    background-size: cover;
    position: relative;
}

.intro-title {
    position: relative;
    bottom: 0;
    left: 0;
}

我得到这个结果:

enter image description here

最佳答案

你只是把相对的转换成绝对的

.pre-content-banner {
    height: 300px;
    background: white url("images/businessppl-bg.jpg") no-repeat center;
    background-size: cover;
    position: relative;
}

.intro-title {
    position: absolute;
    bottom: 0;
    left: 0;
}
.container{
    margin-bottom:30px /*this margin == height of h1*/
}

或者使用javascript改变元素的位置

关于html - 使用 bootstrap 3 将 div 中的文本对齐到底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27876320/

相关文章:

html - 如何使导航栏中的元素居中?

javascript - CSS 中的图像路径在开头添加 '/'(即斜杠)

php - .htaccess 内部重定向不适用于字符串参数

html - 模态在移动浏览器上的显示方式不同

javascript - 可排序和可删除的 Jquery 不断替换 WordPress 中的数据

wordpress - 给予index.html优先于index.php

html - 用 css 打印分页 |分页前 :always; cross-browser issue!

html - 如何使用带有 Angular 的字符串数组在 HTML 模板中显示包含 3 列的表格?

javascript - 如何修复 html 元素以跟随类或 div?

css - 将鼠标悬停在其上时如何更改-webkit-scrollbar宽度