首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在底部对齐div

在底部对齐div
EN

Stack Overflow用户
提问于 2015-06-17 18:31:20
回答 1查看 284关注 0票数 4

我有一个想要在页面底部对齐的div。为此,我使用了以下内容--

代码语言:javascript
复制
<div style="position:fixed;bottom:0;overflow:auto;word-wrap:break-word;display:block" ng-show="noData || failedStatus">
    <div class="alert alert-danger" ng-show="noData" style="overflow:auto;word-wrap: break-word;">
        <!-- something -->
    </div>
    <div class="alert alert-danger" ng-show="failedStatus" style="overflow:auto;word-wrap: break-word;">
        <!-- something -->
    </div>
</div>

这段代码对齐了底部的div,但没有对div内部的单词进行包装。

EN

回答 1

Stack Overflow用户

发布于 2015-06-17 18:48:01

这是Fiddle Demo

您的css中缺少position:absolute;

最推荐的做法是避免内联css,而是让类与父div关联,然后将css应用于它。

代码语言:javascript
复制
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
<style>
.footer-div{
    bottom:0;
    overflow:auto;
    word-wrap:break-word;
    display:block;
    position: absolute;
}
</style>
</head>
<body>
<div class="footer-div" ng-show="noData || failedStatus">
    <div class="alert alert-danger" ng-show="noData" style="overflow:auto;word-wrap: break-word;">
        <!-- something -->
        Some text
    </div>
    <div class="alert alert-danger" ng-show="failedStatus" style="overflow:auto;word-wrap: break-word;">
        <!-- something -->
        Some text
    </div>
</div>
</body>
</html>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/30888959

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档