CSS:顶部导航栏固定位置、分类标题栏、底部提示文案固定位置

news2024/9/20 20:44:10

一、效果图

在这里插入图片描述

页面body的css代码

body {
	position: absolute;
	width: 100%;
	height: 100vh;
	padding: 0;
	margin: 0;
	top: 0;
	left: 0;
	bottom: 0;
	background-color #eee;
	/* overflow: auto;
	overflow-y: scroll; */

	/* ::-webkit-scrollbar {
		display: none;
	} */
}

.content-root {
	width: 100%;
	height: 100vh;
	top: 0;
	left: 0;
	position: absolute;
	padding-bottom: 2.5rem;
	background-color: #7ddcf8;
}

二、顶部导航栏固定位置

页面内容可以上下滑动,顶部导航栏始终固定显示在顶部

css代码

.tool-bar {
	width: 100%;
	height: 3.125rem;
	display: flex;
	/* 固定位置 */
	position: fixed;
	background-color: aqua;
	padding-left: 1rem;
	padding-bottom: 0.9375rem;
	/* 数值越大,表示越会显示在其他堆叠元素之上 */
	z-index: 999;
	align-items: flex-end;
	justify-content: space-between;
	box-sizing: border-box;
}

.back-img {
	width: 1.875rem;
	height: 1.25rem;
	margin-left: 0.16rem;
}

.title {
	position: absolute;
	font-family: PingFangSC, PingFang SC;
	font-size: 1.25rem;
	left: 50%;
	transform: translate(-50%, 0);
	text-align: center;
}

.search {
	position: absolute;
	right: 1rem;
	width: 1.25rem;
	height: 1.25rem;
}

三、分类标题栏

一般项目首页分类列表里的item会显示该类型的标题和一行描述,右边显示icon表示点击可查看更多

css代码

.list-root {
	/* 100%的宽度,减去左右边距的总和 */
	width: calc(100% - 32px);
	height: 11.25rem;
	position: relative;
	margin-top: 1rem;
	margin-left: 1rem;
	/* 左右边距 这里注释掉因为 上面 margin-top, 具体根据实际页面样式进行设置 */
	/* margin: 0 16px; */
	border-radius: 0.5rem;
	background-color: white;
}

.top-type {
	width: 100%;
	height: 3.125rem;
	background-color: aqua;
	border-top-left-radius: 0.5rem;
	border-top-right-radius: 0.5rem;
	background-size: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
}

.type-name {
	margin-left: 1rem;
	font-size: 1rem;
	color: #333333;
	font-family: PingFangSC, PingFang SC;
	font-weight: bold;
	padding: 0;
	text-align: left;
	font-style: normal;
}

.type-desc {
	font-family: PingFangSC, PingFang SC;
	font-weight: 400;
	font-size: 0.875rem;
	margin-left: 0.08rem;
	color: #4a4a4a;
	text-align: left;
	overflow: hidden;
	font-style: normal;
	/* 占位剩余空间 */
	flex: 1;
	/*内容超过后面显示... */
	text-overflow: ellipsis;
	/* 不换行 */
	white-space: nowrap;
}

.type-arrow-img {
	width: 0.875rem;
	height: 1rem;
	margin-right: 1rem;
}

四、底部提示文案固定位置

金融类的项目,一般在首页或者下单页面可以上下滑动,提醒用户的文案固定在底部。

css代码

.bottom-tip {
	width: 100%;
	height: 3.125rem;
	bottom: 0;
	left: 0;
	position: fixed;
	padding-left: 1rem;
	padding-right: 1rem;
	/* 让元素变成一个盒模型, 解决 padding-right 不生效问题*/
	box-sizing: border-box;
	z-index: 999;
	font-size: 0.875rem;
	color: #333333;
	/* 内容居中 */
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #e5e5e5;
}

五、title.css完整代码

body {
	position: absolute;
	width: 100%;
	height: 100vh;
	padding: 0;
	margin: 0;
	top: 0;
	left: 0;
	bottom: 0;
	background-color #eee;
	/* overflow: auto;
	overflow-y: scroll; */

	/* ::-webkit-scrollbar {
		display: none;
	} */
}

.content-root {
	width: 100%;
	height: 100vh;
	top: 0;
	left: 0;
	position: absolute;
	padding-bottom: 2.5rem;
	background-color: #7ddcf8;
}

.content-top {
	width: 100%;
	height: 9.375rem;
	/* 如果需要让下面的内容覆盖在这上面,使用  position: absolute; */
	position: relative;
	background-color: white;
	padding-bottom: 4.125rem;
	align-items: center;
}


.tool-bar {
	width: 100%;
	height: 3.125rem;
	display: flex;
	/* 固定位置 */
	position: fixed;
	background-color: aqua;
	padding-left: 1rem;
	padding-bottom: 0.9375rem;
	/* 数值越大,表示越会显示在其他堆叠元素之上 */
	z-index: 999;
	align-items: flex-end;
	justify-content: space-between;
	box-sizing: border-box;
}

.back-img {
	width: 1.875rem;
	height: 1.25rem;
	margin-left: 0.16rem;
}

.title {
	position: absolute;
	font-family: PingFangSC, PingFang SC;
	font-size: 1.25rem;
	left: 50%;
	transform: translate(-50%, 0);
	text-align: center;
}

.search {
	position: absolute;
	right: 1rem;
	width: 1.25rem;
	height: 1.25rem;
}

.list-root {
	/* 100%的宽度,减去左右边距的总和 */
	width: calc(100% - 32px);
	height: 11.25rem;
	position: relative;
	margin-top: 1rem;
	margin-left: 1rem;
	/* 左右边距 这里注释掉因为 上面 margin-top, 具体根据实际页面样式进行设置 */
	/* margin: 0 16px; */
	border-radius: 0.5rem;
	background-color: white;
}

.top-type {
	width: 100%;
	height: 3.125rem;
	background-color: aqua;
	border-top-left-radius: 0.5rem;
	border-top-right-radius: 0.5rem;
	background-size: 100%;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-wrap: wrap;
}

.type-name {
	margin-left: 1rem;
	font-size: 1rem;
	color: #333333;
	font-family: PingFangSC, PingFang SC;
	font-weight: bold;
	padding: 0;
	text-align: left;
	font-style: normal;
}

.type-desc {
	font-family: PingFangSC, PingFang SC;
	font-weight: 400;
	font-size: 0.875rem;
	margin-left: 0.08rem;
	color: #4a4a4a;
	text-align: left;
	overflow: hidden;
	font-style: normal;
	/* 占位剩余空间 */
	flex: 1;
	/*内容超过后面显示... */
	text-overflow: ellipsis;
	/* 不换行 */
	white-space: nowrap;
}

.type-arrow-img {
	width: 0.875rem;
	height: 1rem;
	margin-right: 1rem;
}

.bottom-tip {
	width: 100%;
	height: 3.125rem;
	bottom: 0;
	left: 0;
	position: fixed;
	padding-left: 1rem;
	padding-right: 1rem;
	/* 让元素变成一个盒模型, 解决 padding-right 不生效问题*/
	box-sizing: border-box;
	z-index: 999;
	font-size: 0.875rem;
	color: #333333;
	/* 内容居中 */
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #e5e5e5;
}

六、title.html完整代码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
		<link rel="stylesheet" href="../css/title.css" />
	</head>
	<body>
		<div class="content-root">
			<div class="content-top">
				<div class="tool-bar">
					<img class="back-img" src="../images/icon_title_back_black.png" />
					<span class="title">title样式</span>
					<img class="search" src="../images/icon_search.png" />
				</div>
				<div style="position: absolute; margin-top: 60px;">这里可以显示banner图</div>
			</div>
			
			<div class="list-root">
				<div class="top-type">
					<span class="type-name">这里显示标题</span>
					<span class="type-desc"> | 这里显示描述内容</span>
					<img class="type-arrow-img" src="../images/icon_arrow_right_black.png" />
				</div>
			</div>
			
			<div class="list-root">
				<div class="top-type">
					<span class="type-name">这里显示标题</span>
					<span class="type-desc"> | 这里显示描述内容</span>
					<img class="type-arrow-img" src="../images/icon_arrow_right_black.png" />
				</div>
			</div>
			
			<div class="list-root">
				<div class="top-type">
					<span class="type-name">这里显示标题</span>
					<span class="type-desc"> | 这里显示描述内容</span>
					<img class="type-arrow-img" src="../images/icon_arrow_right_black.png" />
				</div>
			</div>

			<div class="bottom-tip">
				温馨提示:css 样式多练习、研究浏览器兼容性 css 样式多练习研究浏览器兼容性
			</div>


		</div>
	</body>


</html>

七、testH5源码

点击查看testh5源码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1943881.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

python多进程加速函数运行

python多进程运行可以使函数运行在程序主进程以外&#xff0c;减少主进程的调用&#xff0c;并且可以加速子进程的运行速度   为了测试多进程的加速效果&#xff0c;我们可以通过创建一个包含计算密集型任务的函数&#xff0c;并使用多进程来并行执行这些任务。我们将对比单进…

Telegram曝零日漏洞,可伪装成视频攻击安卓用户

ESET Research在一个地下论坛上发现了一个针对Android Telegram的零日漏洞广告。 ESET将该漏洞命名为“EvilVideo”&#xff0c;并将其报告给Telegram&#xff0c;Telegram于7月11日更新了该应用程序。 EvilVideo允许攻击者发送恶意的有效载荷&#xff0c;这些载荷以视频文件…

《白话机器学习的数学》第2章——学习回归

2.1设置问题 1.机器学习所做的事情正是从数据中进行学习&#xff0c;然后给出预测值。 2.2定义模型 1.一次函数的表达式&#xff1a; 其中θ叫做参数。 在统计学领域&#xff0c;人们常常使用 θ 来表示未知数和推测值。采用 θ加数字下标的形式&#xff0c;是为了防止当未知数…

熟悉set/map了解KV模型和pair结构

set基本介绍 set是key模型,本质是确定一个 元素在不在此容器中,也就是说 set中存储的是一个单一数据 1. set是按照一定次序存储元素的容器 2. 在set中&#xff0c;元素的value也标识它(value就是key&#xff0c;类型为T)&#xff0c; 并且每个value必须是唯一的。set中的元素不…

PHP教程001:PHP介绍和环境配置

文章目录 1、php是什么2、php能做什么3、php程序执行流程4、需要什么基础5、环境介绍5.1、WEB环境5.2、环境集成包3、phpStudio软件下载 1、php是什么 通用&#xff1a;跨平台&#xff0c;如windows、Linux、MacOS开源免费服务器端脚本语言 2、php能做什么 可以快速动态的生…

群管机器人官网源码

一款非常好看的群管机器人html官网源码 搭建教程&#xff1a; 域名解析绑定 源码文件上传解压 访问域名即可 演示图片&#xff1a; 群管机器人官网源码下载&#xff1a;客户端下载 - 红客网络编程与渗透技术 原文链接&#xff1a; 群管机器人官网源码

很酷的仿真翻页书HTML源码,书本页面是加载的图片,基于JQuery实现的翻页特效,结合一些js插件,看起来很酷,在实现在线翻书项目。

仿真翻页书HTML源码https://www.bootstrapmb.com/item/14742 创建一个仿真的翻页书效果在HTML和CSS中可以通过多种方式实现&#xff0c;但通常这也会涉及到JavaScript&#xff08;或jQuery&#xff09;来处理交互和动画。以下是一个简单的示例&#xff0c;展示如何使用HTML、…

openssl 加密

使用tar命令在Linux中加密文件可以通过两种方式实现&#xff1a;使用gzip压缩的同时加密&#xff0c;或者使用加密选项。 1. 使用gzip压缩的同时加密&#xff1a; “ tar cz file1 file2 | openssl enc -e -aes256 -out archive.tar.gz.enc “ – cz&#xff1a;创建tar压缩文…

【数学建模】基于贪心算法的电力市场的输电阻塞管理(附论文及matlab、lingo代码)

适合数学建模新手研究的题目&#xff0c;备战国赛的同学可以拿这道题目练手&#xff0c;本文含论文代码&#xff0c;帮助解题理解思路。 题目&#xff1a; &#xff08;1&#xff09;题目信息&#xff1a; 某电网有若干台发电机组和若干条主要线路&#xff0c;每条线路上的有…

k8s中部署nacos

1 部署nfs # 在k8s的主节点上执行 mkdir -p /appdata/download cd /appdata/download git clone https://github.com/nacos-group/nacos-k8s.git 将nacos部署到middleware的命名空间中 kubectl create namespace middleware cd /appdata/download/nacos-k8s # 创建角色 kub…

鸿蒙界面开发

界面开发 //构建 → 界面 build() {//行Row(){//列Column(){//文本 函数名(参数) 对象.方法名&#xff08;参数&#xff09; 枚举名.变量名Text(this.message).fontSize(40)//设置文本大小.fontWeight(FontWeight.Bold)//设置文本粗细.fontColor(#ff2152)//设置文本颜色}.widt…

乐鑫ACK方案低成本设备开发,智能家居无线技术应用,启明云端乐鑫代理商

随着智能家居行业的蓬勃发展&#xff0c;用户对于智能设备的需求日益增长。乐鑫以其创新的Alexa Connect Kit (ACK) 方案&#xff0c;开启了智能家居设备开发的新篇章。 Alexa Connect Kit&#xff08;ACK&#xff09;方案&#xff0c;不仅提供了一个集成Alexa语音服务的高效开…

Redis八股文(一)

目录 1.什么是Redis&#xff1f; 2.Redis和Memcached有什么区别&#xff1f; 3.为什么Redis作为MySQL的缓存&#xff1f; 4.Redis数据类型及其使用场景分别是什么&#xff1f; 5.五种常见数据类型是怎么实现的&#xff1f; 6.Redis是单线程吗&#xff1f; 7.Redis单线程…

iterm2工具的使用|MAC电脑终端实现分屏|iterm2开启滚动操作

iterm2 工具概括 iTerm2 是一款非常强大的终端工具。 iTerm2 最初是为 macOS 开发的,但也有 Windows 、Linux 发行版&#xff08;Ubuntu、centos…&#xff09;可用。 应用场景 Mac操作系统中想实现终端分屏 iterm2 工具特点 多标签和分屏: 可以在同一个窗口中打开多个标签…

【css】实现扫光特效

对于要重点突出的元素&#xff0c;我们经常可以看到它上面打了一个从左到右的斜向扫光&#xff0c;显得元素亮闪闪的&#xff01;类似于下图的亮光动效 关键步骤 伪元素设置position :absolute【也可以不用伪元素&#xff0c;直接创建一个absolute元素盖在上面】设置渐变line…

基于jeecgboot-vue3的Flowable流程仿钉钉流程设计器-抄送服务处理

因为这个项目license问题无法开源&#xff0c;更多技术支持与服务请加入我的知识星球。 1、因为仿钉钉设计器里抄送人是一个服务任务&#xff0c;所以要根据这个服务任务进行处理 2、前端就是一个抄送&#xff0c;选择人 3、这里用了jeecg的选择人组件 <el-form-item prop…

Java开发之Redis

1、非关系型数据库、快、高并发、功能强大 2、为什么快&#xff1f;内存单线程 非阻塞的IO多路复用有效的数据类型/结构 3、应用&#xff1a;支持缓存、支持事务、持久化、发布订阅模型、Lua脚本 4、数据类型&#xff1a; 5 种基础数据类型&#xff1a;String&#xff08;字…

【深度学习】LDA线性判别分析

date:2024/07/23 author:sion tag:Deeping Learn LDA(线性判别分析) 文章目录 LDA(线性判别分析)1.LDA是什么LDA是一种解决二分类问题的线性方法。它描述&#xff0c;对于给定样例集&#xff0c;将样例点投影到一条直线上&#xff0c;这条直线能使异样的样例相距远&#xff0c;…

three完全开源扩展案例05-围栏着色器

https://www.threelab.cn/three-cesium-examples/public/index.html#/codeMirror?navigationThree.js%E6%A1%88%E4%BE%8B[r166]&classifyshader&idfenceShader 更多案例 import * as THREE from three import { OrbitControls } from three/examples/jsm/controls/O…

【分布式锁】Redission实现分布式锁

接着上一节&#xff0c;我们遇到了超卖的问题&#xff0c;并通过Redis实现分布式锁&#xff0c;进行了解决。本节 我将换一种方式实现分布式锁。 前提&#xff1a; nginx、redis、nacos 模块1&#xff1a; provider-and-consumer 端口 8023 模块2 rabbitmq-consumer 端口 8021 …