html - 如何修复页脚?

标签 html css

问题代码https://jsfiddle.net/ftbpmw7c/ 它在网格后上升,我该如何解决? 我想让我的页脚固定 html代码



    <footer>
        <li><a href="">Menu</a></li>
        <li><a href="">Menu</a></li>
        <li><a href="">Menu</a></li>
        <li><a href="">Menu</a></li>
        <li><a href="">Menu</a></li>

         </footer>
    css code:   
  footer{

    width: 100%;
    height: 150px;
      background: black;
      display:grid;
      grid-template-columns: repeat(5, auto);
      clear: both;

  }
  li {
      float: left;
  }
  footer li a{
      display: block;
      line-height: 1.5;
  }



最佳答案

只需按照以下步骤操作即可获得所需的结果。

  1. <header>nav之后关闭
  2. 将评论框移到iframe下方
  3. 使用间距、宽度、高度和网格来正确对齐。

找到 fiddle here .

var disqus_config = function() {
    this.page.url = 'http://example.com/2017/08/02/postid=998'; // Replace PAGE_URL with your page's canonical URL variable
    this.page.identifier = '/2017/08/02/postid=998'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};

(function() { // DON'T EDIT BELOW THIS LINE
    var d = document,
        s = d.createElement('script');
    s.src = 'https://coinspy.disqus.com/embed.js';
    s.setAttribute('data-timestamp', +new Date());
    (d.head || d.body).appendChild(s);
})();
* {
    box-sizing: border-box;
    position: relative;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: #161616;
    box-sizing: border-box;
    width: 100%;
}

nav {
    background: white;
    height: 100px;
    width: 100%;
}

nav ul {
    padding: 30px 0 0;
}

ul {
    margin: 0;
    list-style: none;
    padding: 0;
    width: 1
}

ul li {
    float: left;
}

ul li a {
    font-style: 1.5em;
    display: block;
    padding: 1px 20px;
}

nav > img {
    width: 80px;
    position: absolute;
    right: 10px;
    top: 8px;
}

.section1 {
    margin-top: 10px;
    width: 100%;
    height: 400px;
    display: grid;
    grid-template-columns: repeat(3, auto);
    grid-gap: 3px;
    grid-column-gap: auto;
    justify-content: center;
    justify-items: center;
}

.iframe1 {
    border: 1px solid black;
    position: relative;
    margin: 0 auto;
    margin-bottom: 0px;
    margin-bottom: 1px;
    max-width: 640px;
}

.container1 {
    display: grid;
    grid-template-columns: repeat(2, auto);
    height: 300px;
    width: 100%;
}

.box1 {
    width: 300px;
    height: 300px;
    background: red;
    padding: 50px 15px;
    box-sizing: border-box;
}

.box2 {
    width: 300px;
    height: 300px;
    background: red;
}

.box3 {
    width: 300px;
    height: 300px;
    background: red;
}

.side1 {
    width: 180px;
    float: left;
    position: sticky;
    top: 0;
}

.side2 {
    width: 180px;
    float: right;
    position: sticky;
    top: 0;
    background-color: blue;
}

footer {
    width: 100%;
    height: 150px;
    background: black;
    display: grid;
    grid-template-columns: repeat(5, auto);
    clear: both;
    text-align: center;
}

footer li {
    float: left;
}

footer li a {
    display: block;
    line-height: 1.5;
}

.section2 {
    max-width: 640px;
    margin: 0 auto;
    margin-bottom: 20px;
}

.disqus_thread {
    width: 500px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header>
    <nav>
        <img src="https://brandmark.io/logo-rank/random/pepsi.png" alt="logo">
        <ul>
            <li><a href="">Home</a></li>
            <li><a href="">Menu</a></li>
            <li><a href="">Contact</a></li>
            <li><a href="">Menu</a></li>
            <li><a href="">Menu</a></li>
        </ul>
    </nav>
</header>
<section class="section1">
    <div class="box box1">
        <iframe width="250px" height="200px" src="https://www.youtube.com/embed/cKGPrOLIt7M" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
    </div>
    <div class="box box2"></div>
    <div class="box box3"></div>

</section>
<hr>
<div class="iframe1">
    <iframe SRC="https://www.mp4upload.com/embed-nbyvbffoyerp.html" FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=640 HEIGHT=250 allowfullscreen></iframe>
</div>
<section class="section2">
    <div id="disqus_thread"></div>

    <noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>

</section>
<div class="container1">
    <img class="side1" src="https://via.placeholder.com/1536x2408" alt="">

    <img class="side2" src="https://via.placeholder.com/1536x2408" alt="">
</div>

<footer>
    <li><a href="">Menu</a></li>
    <li><a href="">Menu</a></li>
    <li><a href="">Menu</a></li>
    <li><a href="">Menu</a></li>
    <li><a href="">Menu</a></li>

</footer>

关于html - 如何修复页脚?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55860122/

相关文章:

jquery - jQuery 中的粘性悬停

javascript - 通过javascript获取图片

javascript - 如何在滚动过程中不跳动的情况下将粘性标题居中?

javascript - 使用 javascript 更改纸张颜色

html - 如何制作具有网页高度的 slider ?

android - 如何将css文件从url渲染到android中的webview

html - 选择 class 还是 <nav> 元素更可取?

css - 更改选择菜单中的选项颜色

javascript - Jquery:根据属性将css类添加到某些div

html - css中的居中按钮