html - 我怎样才能得到一个页脚,每台显示器都有 2 个内容 100% 的长度

标签 html css

我想为我的元素创建一个页脚,但现在我遇到了如何使页脚达到显示器的全尺寸的问题。我有我的页脚代码,然后是我的 CSS。

.container {
    text-decoration: none;
    background-color: #333;
    float: left;
    display: block;
}

.container h1 {
    font-size: 18px;
    font-family:'Roboto Condensed', 'sans-serif';
    padding-left: 20px;
    padding-top: 20px;
    padding-bottom: 6px;
}

.container a {
    text-decoration: none;
    font-size: 16px;
    color: rgba(106,106,106,1.00);
    padding-left: 20px;
    padding-right: 20px;
}

.container a:hover {
    color: maroon;
}
<footer>
        <div class="container">
            <h1>Finanzdienstleistung</h1>
            <a href="#">Versicherungen</a><br>
            <a href="#">Schadensabwickelung</a>
        </div>
        <div class="container">
            <h1>Vermietung</h1>
            <a href="#">Freie Wohnungen</a><br>
            <a href="#">Alle Wohnungen</a>
        </div>
</footer>

最佳答案

您可以将它们变成 display: table-cell 而不是 float ,以将它们保持在一行中并填充整个宽度:

footer {
  display: table;
  width: 100%;
}

.container {
    text-decoration: none;
    background-color: #333;
    display: table-cell;
}

.container h1 {
    font-size: 18px;
    font-family:'Roboto Condensed', 'sans-serif';
    padding-left: 20px;
    padding-top: 20px;
    padding-bottom: 6px;
}

.container a {
    text-decoration: none;
    font-size: 16px;
    color: rgba(106,106,106,1.00);
    padding-left: 20px;
    padding-right: 20px;
}

.container a:hover {
    color: maroon;
}
<footer>
        <div class="container">
            <h1>Finanzdienstleistung</h1>
            <a href="#">Versicherungen</a><br>
            <a href="#">Schadensabwickelung</a>
        </div>
        <div class="container">
            <h1>Vermietung</h1>
            <a href="#">Freie Wohnungen</a><br>
            <a href="#">Alle Wohnungen</a>
        </div>
</footer>

关于html - 我怎样才能得到一个页脚,每台显示器都有 2 个内容 100% 的长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42961024/

相关文章:

html - 使用 CSS 操作外部 svg 文件样式属性

javascript - 使用 d3 从 `multiple` 下拉菜单中查找用户选择的选项?

jquery - 设置三种不同字体大小的容器

html - 展开时固定元素的位置

CSS Cod5 Rain 用户名?它可以编码吗?如果可以,我将如何处理

css - 拉/推中的 Bootstrap 故障

html - 将一堆 <li> 的第二行居中而不添加 div?

html - 由于 float 在另一个元素上,div 元素未按应有的方式显示

html - Ionic2 Grid with buttons - 如何让按钮排成一排,高度相同?

javascript - 通过搜索过滤内容