将底栏div紧贴网页底部的方法

有时候网页的内容不够多,但是,想底栏贴紧浏览器的底部;但是在网页内容充足的时候,希望底栏在页面的底部,这个CSS似乎是没有办法实现,只能够借助js了。

 

写了很多小的代码,放在硬盘里面,把它翻出来都要时间,还不如挂到网上。

 

 

$(document).ready(function(){
	if (document.documentElement.clientHeight > document.body.scrollHeight) {
		$("#push-clear-fix").css("height",document.documentElement.clientHeight - document.body.scrollHeight);
	};
	$(window).resize(function(){
		$("#push-clear-fix").css("height",$(window).height() - (document.body.scrollHeight - $("#push-clear-fix").height() ));
	});
});

 

这篇博文发表在 网页设计 | Web Design 目录下,标签为 , ,
如需引用,请使用链接:https://note.mc256.dev/?p=423

This article published in 网页设计 | Web Design with tags , , .
Cite this page using this link:https://note.mc256.dev/?p=423

您的邮箱地址不会被公开,评论使用Gravatar头像。
Your email address will not be published. This blog is using Gravatar.

正在提交评论... Submitting ...
正在为您准备评论控件 Loading Comment Plugin
Copyright © 2013-2024 mc256. All Rights Reserved.
Powered by WordPress on top of a dual-stack k3s Cluster using JuiceFS.
Wordpress Theme Designed By mc256.
Encrypted By Let's Encrypt.  Hosted On Linode + OVH + AWS.
DNS Provided By Hostker.
Status Page by CloudFlare Worker.