Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jQuery修复底部的页脚_Jquery_Html_Css - Fatal编程技术网

使用jQuery修复底部的页脚

使用jQuery修复底部的页脚,jquery,html,css,Jquery,Html,Css,我想把我的页脚固定在底部间隙。如果内容较少,则会出现页脚,内容已满的问题已解决,页脚应固定在底部,同时我将放大或缩小。但当我缩放页脚时,页脚将转到内容部分 <head runat="server"> <asp:contentplaceholder id="HeaderContent" runat="server"></asp:contentplaceholder> </head> <body cla

我想把我的页脚固定在底部间隙。如果内容较少,则会出现页脚,内容已满的问题已解决,页脚应固定在底部,同时我将放大或缩小。但当我缩放页脚时,页脚将转到内容部分

    <head runat="server">
        <asp:contentplaceholder id="HeaderContent" runat="server"></asp:contentplaceholder>
    </head> 

    <body class="hidden-sn white-skin backcolor">
    <form id="form1" runat="server">
    <main>
    <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"></asp:contentplaceholder>
    </main>
    <!--main layout-->
    <!--footer-->
    <footer id="footer" style="position:relative;bottom: 0;left: 0;width: 100%; height: 50px;text-align: center; color: rgba(255, 255, 255, 0.6); line-height: 50px; overflow: hidden; font-size: 0.9rem; background-color: rgba(62, 69, 81, 0.3)">
        <div class="footer-copyright">
            <div class="container-fluid">
                © copyright 2016 transgraph consulting pvt.ltd, all rights reserved.
            </div>
        </div>
    </footer>
    </body>
    </html>

©版权所有2016海普咨询私人有限公司,保留所有权利。
这是我的主页

    position: relative ---> if content is less coming up.
    position: absolute and fixed ----> if content is more getting on content. 


var docHeight = $(window).height();
          var footerHeight = $('#footer').height();
           var footerTop = $('#footer').position().top + footerHeight;
          if (footerTop < docHeight) {
               $('#footer').css('margin-top', 0 + (docHeight - footerTop) + 'px');
            }
position:relative--->如果出现的内容较少。
位置:绝对和固定---->如果内容更接近内容。
var docHeight=$(window.height();
var footerHeight=$('#footer').height();
var footerTop=$('#footer').position().top+footerHeight;
如果(页脚顶部<八){
$(“#footer').css('margin-top',0+(docHeight-footerTop)+'px');
}

我使用jQuery来修复它。将我的页脚固定在底部。建议我使用CSS或jQuery解决此问题。我想修复底部间隙处的页脚。如果内容较少,则会出现页脚,内容已满的问题已解决,页脚应固定在底部,同时我将放大或缩小。但是当我缩放页脚时,页脚将转到内容部分,而不使用Jquery

    <head runat="server">
        <asp:contentplaceholder id="HeaderContent" runat="server"></asp:contentplaceholder>
    </head> 

    <body class="hidden-sn white-skin backcolor">
    <form id="form1" runat="server">
    <main>
    <asp:contentplaceholder id="ContentPlaceHolder1" runat="server"></asp:contentplaceholder>
    </main>
    <!--main layout-->
    <!--footer-->
    <footer id="footer" style="position:relative;bottom: 0;left: 0;width: 100%; height: 50px;text-align: center; color: rgba(255, 255, 255, 0.6); line-height: 50px; overflow: hidden; font-size: 0.9rem; background-color: rgba(62, 69, 81, 0.3)">
        <div class="footer-copyright">
            <div class="container-fluid">
                © copyright 2016 transgraph consulting pvt.ltd, all rights reserved.
            </div>
        </div>
    </footer>
    </body>
    </html>
CSS:

HTML:


CSS“始终在底部”页脚
正文

正文

正文

正文

此页脚将始终位于页面底部,但不是固定的。
为什么不使用引导? 这更容易。 链接:,

在这里检查这段代码,它将帮助您在底部制作固定的页脚,并且在您缩小或放大时应该是固定的

<div class="content">
<h1>Some Thing You Want to do</h1>
</div>
<footer class="footer">Footer</footer>

html, body {
height: 100%;
margin: 0;
}
.content {
padding: 20px;
min-height: 100%;
margin: 0 auto -50px;
}
.footer,
.push {
 height: 50px;
}

* {
box-sizing: border-box;
}
body {
font: 16px Sans-Serif;
}
h1 {
margin: 0 0 20px 0;
}
p {
margin: 20px 0 0 0;
}
footer {
background: #42A5F5;
color: white;
line-height: 50px;
padding: 0 20px;
}

你想做什么
页脚
html,正文{
身高:100%;
保证金:0;
}
.内容{
填充:20px;
最小高度:100%;
保证金:0自动-50px;
}
.页脚,
.推{
高度:50px;
}
* {
框大小:边框框;
}
身体{
字体:16px无衬线;
}
h1{
利润率:0.20px0;
}
p{
利润率:20px0;
}
页脚{
背景#42A5F5;
颜色:白色;
线高:50px;
填充:0 20px;
}
您可以在这里找到演示链接,该链接可能与
<div class="content">
<h1>Some Thing You Want to do</h1>
</div>
<footer class="footer">Footer</footer>

html, body {
height: 100%;
margin: 0;
}
.content {
padding: 20px;
min-height: 100%;
margin: 0 auto -50px;
}
.footer,
.push {
 height: 50px;
}

* {
box-sizing: border-box;
}
body {
font: 16px Sans-Serif;
}
h1 {
margin: 0 0 20px 0;
}
p {
margin: 20px 0 0 0;
}
footer {
background: #42A5F5;
color: white;
line-height: 50px;
padding: 0 20px;
}