gpt4 book ai didi

php - 页脚没有显示我想要的方式

转载 作者:太空宇宙 更新时间:2023-11-04 04:13:18 24 4
gpt4 key购买 nike

所以,一段时间以来,我一直在尝试找出如何正确放置页脚的方法。我在 SO 上浏览了一些已经提出的问题,我发现了一些我实现的想法,但这些想法并没有让我的页脚工作。

这是基本的解释。我为我的页脚编写了以下代码。问题是如果帖子不长,页面中的页脚会“飞起来”。我正在编写(最好说是重写)一个从 C 到 PHP 的简单 CMS,我不喜欢 CSS 或整体设计。

代码如下:

#footer {
position: static;
background: #346 repeat scroll 0 0;
border-top:3px solid #CCCCCC;
clear: both;
color:#FFFFFF;
font-size:x-small;
line-height:100%;
margin: 2em 0 0;
width: 100%;
text-align: center;
padding:3px 10px 10px;
bottom: 0;
}

单个帖 subview (不好,您会看到页脚下方留有空白): single post
(来源:easycaptures.com)

很少有帖子填满整个页面(很好,页脚在分页下方): full view
(来源:easycaptures.com)

另一方面,当我将 position 设置为 fixed 时,我有这个溢出: Bug
(来源:easycaptures.com)

如何使我的代码像图片中显示的那样正常工作(好)?

编辑:对于那些说要改变位置的人,我已经尝试了所有位置属性(静态、绝对、固定、相对、继承)。

这是我的容器代码:

#contener {
margin: 0 auto;
text-align: left;
width: 100%;
}

其他:

body, html, #menu, img, a img, form, fieldset {
margin:0;
padding:0;
font-size: 12px;
}


当我将位置设置为“绝对”时,我得到了这个 picture .

这是我的分页+页脚的完整代码:

<?php
$currentPage = 1;
if(isset($_GET['page'])){
$currentPage = protect_sqli($_GET['page']);
}

$e = $currentPage * $num_psts; // end post
$p = $e - $num_psts+1; // start post
$i = 0;

// Create a connection
$conS = mysqli_connect($hName, $dbUser) or die(mysql_error());

// Select a specific database
mysqli_select_db($conS, $dbName) or die(mysql_error());

// Query creating
$result = mysqli_query($conS, "SELECT * FROM posts ORDER BY dat DESC, tim DESC");
while($row = mysqli_fetch_array($result))
{
$i++;
if($i >= $p && $i <= $e)
{
$postId = protect_sqli($row['slug']);
readfile('p/' . $postId . '.php');
}
}

?>

<center>
<p>
<?php
$result = mysqli_query($conS, "SELECT id FROM posts");
$nPosts = mysqli_num_rows($result); // number of posts

mysqli_close($conS);

echo "Pages: ";

$pages = $nPosts/$num_psts; // number of pages

for($i = 1; $i < $pages+1; $i++)
{
if($i == $currentPage)
{
echo "<strong>".$i."</strong> ";
}
else
{
echo "<a href=\"?page=". $i ."\">". $i ."</a> ";
}
}

?>
</p>
</center>

<div id="footer">
<?php readfile(__DIR__ . "/mvc/fe/footer.php"); ?>
</div>
</div>

页脚.php:

Made by dn5 | <a href="https://github.com/dn5/cblogphp" target="_blank"><font color="#e1c1aa">cblogphp</font></a>

最佳答案

你的意思是粘性footer哪个始终位于您网站的底部?

CSS 是这样的:

html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -155px; /* the bottom margin is the negative value of the footer's height */
}
.footer, .push {
height: 155px; /* .push must be the same height as .footer */
}

关于php - 页脚没有显示我想要的方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20333439/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com