当前位置:首页 > 网站应用

3种js+css实现移动设置底部固定菜单,极简方法

cjw1233年前 (2023-11-01)网站应用6970

解开css中注释,共3种方式,推荐flex方法。

<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title>移动端固定底部菜单</title>
</head>
<body>
<!--
<p>以百分数为主,但px(固定)要弃之。
vw,1vw视口宽度的1%;</p>
<p>定位(position)->布局(flex)->内容位置(div)</p>
<p>vh,vw,%,flexbox,vh,vw,rem,em</p>
-->
<div class="box">
	<div class="roll">滚动结构
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />	
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />	
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构
		<br />
		滚动结构3
		<br />
		滚动结构2
		<br />
		滚动结构1
		<br />
	</div>
	<footer>底部结构菜单</footer>

</div>
<style>
	html,body{
		margin: 0;
		padding: 0;
		height: 100%;
		width: 100%;
	}
	footer{
		background: green;
		width: 100%;
		font-size: 4vh;		
	}
	/*1.css固定定位,比底部菜单多一个vh
	.roll{
		padding-bottom: 5vh;
	}
	footer{
		position: fixed;
		bottom: 0;
		z-index: 999;
	}
	end 1*/
	/*css相对定位
	.box{
		position: relative;
		height: 100%;
	}
	.roll{
		position:absolute;
		top:0;
		bottom:5vh;
		width: 100%;
		height: auto;
		overflow-y: scroll;
		-webkit-overflow-scrolling:touch;

	}
	footer{
		position: absolute;
		bottom: 0;
	}
	end 2*/
	/*3 弹性布局,推荐*/
	.box{
		display: flex;
		display: -webkit-flex;
		height: 100%;
		flex-direction: column;
	}
	.roll{
		flex:1;
		width: auto;
		width: 100%;
		overflow-y: scroll;
		-webkit-overflow-scrolling:touch;
	}
</style>
</body>
</html>


扫描二维码推送至手机访问。

版权声明:本文由追求完美发布,如需转载请注明出处。

本文链接:https://cjw123.com/blog/?id=29

标签: htmljscss
分享给朋友:

相关文章

html meta标签屏蔽搜索引擎的用法

html页面中的 meta 标签可以用来识别搜索引擎的蜘蛛类型,可以规定meta标签所在的html页面是否被蜘蛛抓取,下面是这个meta标签的用法,大家可以借鉴一下。搜索引擎的 meta 标签的解析下面是meta标签对搜索引擎的解析<meta name='robot…

一个网站网页快照截图的接口

如果您的网站想展示某个网站的快照截图的话使用这个网页快照截图的接口确实比较方便网页快照截图接口使用https://s0.wp.com/mshots/v1/网址?w=宽度&h=高度示例https://s0.wp.com/mshots/v1/www.cjw123.com?w=1900&h…

zblogphp二级目录建站,伪静态规则怎么写

如果你的 Z-BlogPHP 站点安装在二级目录中,需要使用伪静态技术来优化站点的 URL,并提升搜索引擎蜘蛛的抓取效率。下面是一个 nginx 的伪静态规则示例:# 子目录规则要排在前边; location /sub/ {    &n…

js+css3文字闪光滑过动画特效

<!DOCTYPE html>     <html>     <head>     <meta http-equ…

google谷歌翻译镜像网站

查找外文资料对于外语不好的那必须要借助翻译工具,各家翻译工具各有不同,想要使用google谷歌翻译,奈何无法访问,那么如何在国内使用谷歌翻译?google谷歌翻译镜像网站有哪些?https://translate.yunkuerp.cn/https://translate.renwole.com/h…

开灯!关灯!

<!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8">…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。