【问题标题】:Sticky footer with include php带有包含 php 的粘性页脚
【发布时间】:2016-10-02 14:25:34
【问题描述】:
<DOCTYPE! html>
<head>
<link rel="stylesheet" type="text/ccs" href="css/indexcss.css">
</head>

<body>
<div id="wrapper">
    <div id="header">
    <?php
        include("utilbar.php");
        include("navbar.php");
    ?>
    </div>

    <?php 
        if (isset($_GET["type"])) {
            $page = $_GET["type"];
        }
        else {
            $page = "home";
        }

        //echo "<body onload=\"changeContent('".$page."')\">";
    ?>

    <!--script>
    function contentOnload() {
        window.location.href('content.php');
    }
    </script-->

    <script>
    function navClick(contentName)
    {
        window.location.href = "index.php?type=" + contentName;
    }
    </script>

    <div class="container">
    <?php include($page.".php"); ?>
    </div>

    <div class="footer">
        <?php include("footer.html"); ?>    
    </div>
</div>
</body>
</html>

这里是 CSS:

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}
.container {
    width: 100%;
    margin: auto;
    margin-top: 0;
    padding: 0;
}
.footer {
    bottom: 0;
    position: absolute;
}

所以我试图让页脚贴在我所有包含的内容下方,但有时它会跳到包含文件的内容之上。我查找了大多数可能的粘性页脚指南并尝试应用它们,但似乎没有一个像它们应该的那样工作。一段时间以来,我一直在尝试解决此问题。

这是页脚 HTML CSS:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/footercss.css">
    <title>Footer</title>
</head>
<body>
<div id="containerf">
    <div id="logos"></div>
    <div id="foottext">
        <a href="http://youtube.com" target="_blank"><img src="images/youtube.png" height="25" width="25"></a>
        <a href="http://twitter.com" target="_blank"><img src="images/twitter.png" height="25" width="25"></a>
        <a href="http://facebook.com" target="_blank"><img src="images/fbtrp.png" height="25" width="25"></a>   
        <b>| Schaafstraat 137 | &copy; 2016 Kopala | All rights reserved.</b>
    </div>
</div>
</body>
</html>

#containerf {
    width: 100%;
    height: 180px;
    background-color: #006666;
    position: absolute;
    bottom: 0;
    margin-bottom: 500px;
}

#foottext {
    line-height: 180px;
    text-align: center;
    color: #d9d9d9;
}

#foottext img {
    padding-right: 5px;
}

【问题讨论】:

  • "Here's the footer html css" - 为什么该文件中有 HTML 标记和 CSS?应该只有你的div。问题不清楚什么代码体是什么文件名。
  • 查看您的(渲染的)HTML 源代码,您就会明白我的意思,这将是一团糟。
  • sticky footer question的可能重复
  • 我已经清理了这里的格式。下一次,在发帖前对其进行格式化,以便人们阅读和理解。

标签: php html css footer sticky


【解决方案1】:

您在哪个文件中将 .footer 设置为底部:0; ?您似乎在常规 style.css 中声明了它,但在 fotter.htm 中包含 footercss.css

你应该粘贴底部:0;到footercss.css

【讨论】:

猜你喜欢
  • 2012-12-28
  • 2018-10-29
  • 1970-01-01
  • 1970-01-01
  • 2018-03-26
  • 2016-07-02
  • 1970-01-01
  • 2023-04-02
  • 1970-01-01
相关资源
最近更新 更多