【问题标题】:html footer doesn't workhtml页脚不起作用
【发布时间】:2014-08-01 09:35:58
【问题描述】:

当我写这篇文章时,Hello 这个词出现在我的页面顶部而不是底部:

<footer> Hello </footer>

这是我的 CSS 文件的重要部分:

.footer{
    position:fixed;
    bottom:0;
    left:0;
    height:100px;
    background: black;
}

我真的不知道怎么了。 我在 Ruby on Rails 下工作,我正在使用 Pdfkit 将我的 html 页面转换为 pdf,但我认为这并不重要。

【问题讨论】:

  • 只使用页脚 {...} 而不是 .footer,它不是一个类而是一个标签。

标签: html css ruby-on-rails footer


【解决方案1】:

Demo

页脚是您的 html 中的标签,而不是类

footer {
    position:fixed;
    bottom:0;
    left:0;
    height:100px;
    width: 100%;
    background: black;
}

【讨论】:

    【解决方案2】:

    在 CSS 中,将 .footer 替换为 footer,它将起作用,并且工作的小提琴就在这里

    fiddle

    只是为了您的澄清。

    在 html 中,我们创建标签,其中一些标签具有 classid 等属性。下面展示了如何分配 CSS。

    如果class 是属性,那么您使用.

    <div class="new"/>
    CSS would be 
    .new{}
    

    如果属性是id,那么你使用#

    <div id="new"/>
    CSS would be
    #new{}
    

    如果 css 直接在标签上,没有属性,直接使用标签。 (这就是你卡住的地方)

    <div/>
    CSS would be
    div{}
    

    编码愉快!!!!

    【讨论】:

      猜你喜欢
      • 2018-08-21
      • 1970-01-01
      • 2011-06-27
      • 1970-01-01
      • 1970-01-01
      • 2013-07-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多