doufang6268 2019-03-10 11:32
浏览 90

索引页脚很古怪

I'm pretty new to programming/web development (this is my first website essentially) and for some reason, my footer on the index.php page does not have any padding on the top (every other page the footer is perfectly fine).

Index.php

<?php 
include('includes/header.php');
?>

<div class="main-body">
    <div id="box-1">
        <h2>WELCOME TO</h2>
    </div>
    <div id="box-2">
        <h2>TOTALLY<br> EDUCATIONAL</h2>
    </div>
</div>

<?php 
    include('includes/footer.php') 
?>

footer.php

<footer>
    <h5>© 2019 Totally Educational. All Rights Reserved.</h5>
</footer>

</body>
</html>

style.css(index)

/*INDEX PAGE*/

/*side-by-side box structure*/

.main-body {
    box-sizing: border-box;
    display: inline;
    padding: 0;
    margin: 0;
    border: 0;
    font-size: 10px;
    text-align: center;
}

#box-1 {
    width: 49.5%;
    background-color: rgba(126,121,121,1.00);
    float: left;
    height: 600px;
    border-right: solid;
    border-right-width: 2px;
}

#box-2 {
    width: 50%;
    background-color: white;
    float: left;
    height: 600px;
}

/*side-by-side box styling*/

#box-1 h2 {
    padding: 300px 0;
    letter-spacing: 5px;
    color: white;
}

#box-2 h2 {
    padding: 300px 10%;
    letter-spacing: 5px;
}

style.css(footer)

#footer, #footer h5 {
    background-color: black;
    color: white;
    padding: 20px 0;
    margin: 0;
    text-align: center;
    width: 100%;
}

Above is all the PHP and CSS relevant to the problem. Basically, when I run it the index page footer h4 has no padding at the top and there's a white strip underneath it. For every other page, this problem didn't occur, only in the index.php. I wrote all this in the span of 3 or so days and I'm just starting to learn everything so it's probably some stupid newby thing I've done but any help would be much appreciated. I'll also attach some images of what it looks like.

index.php screenshot
games.php screenshot

-jEK01

  • 写回答

1条回答 默认 最新

  • 普通网友 2019-03-10 11:44
    关注

    Try use inline-block for .main-body, and add clear:both; to #footer:

    .main-body {
        box-sizing: border-box;
        display: inline-block;
        padding: 0;
        margin: 0;
        border: 0;
        font-size: 10px;
        text-align: center;
    }
    #footer, #footer h5 {
      background-color: black;
      clear:both;
      color: white;
      padding: 20px 0;
      margin: 0;
      text-align: center;
      width: 100%;
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭