固定定位 z-index iconfont的使用 043
固定定位 现象 脱标 提升层级 将盒子固定住
参考点 浏览器的左上角 :
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="./css/reset.css">
<style>
body{
padding-top: 80px;
} .header{
width: 100%;
height: 80px;
background-color: red;
/*固定定位*/
position: fixed;
top: 0;
left: 0;
} </style>
</head>
<body style="height: 2000px">
<div class="header"></div>
<p>I am alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
</body>
</html>
reset.css(重置样式) 直接引用就行
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/ html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
回到顶部案例
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="./css/reset.css">
<style>
.backTop{
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
background-color: black;
position: fixed;
right: 20px;
bottom: 20px;
}
a{
text-decoration: none;
}
.backTop a{ color: #fff;
} </style>
</head>
<body style="height: 2000px">
<div id="top"></div>
<div class="backTop">
<!--阻止a标签的默认事件-->
<a href="javascript:void(0);">回到顶部</a>
</div>
<!--from xxx import ooo-->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script>
// def $(str):
// .....
// return 对象
//
// $() $('a').click(function(){
// 业务逻辑 $('body,html').animate({
scrollTop:0
},1000); }) </script> </body>
</html>
z-index :有四大特征:
与固定定位有关系 默认为0 越大表层级越高
1 z-index值表示谁压着谁,数值大的压盖数值小的
2 只有定位了的元素才能有z-index ,也即 不管线对定位 绝对定位 固定定位都可以使用z-index 浮动元素不能设置z-index
3 z-index值没有单位 就是一个正整数 默认的是0如果都没有z-index值 那么谁写在HTML后面 谁在上面压着别人 定位了的元素 永远压着没有定位的元素
4 从父现象 父亲怂了 儿子再牛逼也没有用
父子的z-index
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.father1,.father2{
width: 400px;
height: 400px; }
/*父亲怂了 儿子再牛逼也没用*/
.father1{
background-color: red;
position: absolute;
z-index: 10;
}
.father2{
background-color: green;
position: absolute;
z-index: 3;
}
.child1,.child2{
width: 200px;
height: 200px; }
.child1{
background-color: darkmagenta;
position: absolute;
top: 350px;
left: 450px;
z-index: 5;
}
.child2{
background-color: #ff6700;
position: absolute;
top: 350px;
left: 420px;
z-index: 10000;
} </style>
</head>
<body>
<div class="father1">
<div class="child1"></div>
</div>
<div class="father2">
<div class="child2"></div>
</div> </body>
</html>
iconfont 的使用
iconfont
http://www.iconfont.cn/
IconFont 图标
unicode是字体在网页端最原始的应用方式,特点是:
兼容性最好,支持ie6+,及所有现代浏览器。
支持按字体的方式去动态调整图标大小,颜色等等。
但是因为是字体,所以不支持多色。只能使用平台里单色的图标,就算项目里有多色图标也会自动去
色。
注意:新版iconfont支持多色图标,这些多色图标在unicode模式下将不能使用,如果有需求建议使用
symbol的引用方式
unicode使用步骤如下:
第一步:拷贝项目下面生成的font-face
@font-face {
font-family: 'iconfont';
src: url('iconfont.eot');
src: url('iconfont.eot?#iefix') format('embedded-opentype'),
url('iconfont.woff') format('woff'),
url('iconfont.ttf') format('truetype'),
url('iconfont.svg#iconfont') format('svg');
}
第二步:定义使用iconfont的样式
.iconfont{
font-family:"iconfont" !important;
font-size:16px;font-style:normal;
-webkit-font-smoothing: antialiased;
-webkit-text-stroke-width: 0.2px;
-moz-osx-font-smoothing: grayscale;
}
第三步:挑选相应图标并获取字体编码,应用于页面
<i class="iconfont">3</i>
"iconfont"是你项目下的font-family。可以通过编辑项目查看,默认是"iconfont"。
固定定位
固定定位的现象
脱标
提升层级
页面内容一多,盒子固定住
参考点
以浏览器的左上角
固定导航栏
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="./css/reset.css">
<style>
body{
padding-top: 80px;
}
.header{
width: 100%;
height: 80px;
background-color: red;
/*固定定位*/
position: fixed;
top: 0;
left: 0;
/*提升层级*/
z-index: 99999;
}
.active{
position: relative;
}
</style>
</head>
<body style="height: 2000px">
<div class="header"></div>
<p>我是alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p>alex</p>
<p class="active">alex</p>
</body>
</html>
回到顶部
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="./css/reset.css">
<style>
.backTop{
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
background-color: black;
position: fixed;
right: 20px;
bottom: 20px;
}
a{
text-decoration: none;
}
.backTop a{
color: #fff;
}
</style>
</head>
<body style="height: 2000px">
<div id="top"></div>
<div class="backTop">
<!--阻止a标签的默认事件-->
<a href="javascript:void(0);">回到顶部</a>
</div>
<!--from xxx import ooo-->
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.js"></script>
<script>
// def $(str):
// .....
// return 对象
//
// $()
$('a').click(function(){
// 业务逻辑
$('body,html').animate({
scrollTop:0
},1000);
})
</script>
</body>
</html>
固定定位 z-index iconfont的使用 043的更多相关文章
- 移动端底部fixed固定定位输入框ios下不兼容
简短记录下最近开发移动端项目碰到的小坑,产品需求做一个售后对话页面,底部固定输入框,和微信对话差不多,但是在ios下,fixed失效,输入框被虚拟键盘挡住,在安卓下是正常的. 尝试过网上说的很多方法, ...
- 实现 DIV 固定定位在网页主体部分最右侧
position:fixed 相对于窗口的固定定位,这个窗口可理解为可视窗口,除了浏览器自己的东西,剩下的就是这个可视窗口.而大部分的网页都是窄屏设计,比如说网页主体部分固定宽 1200px,或者自适 ...
- angular 实现左侧和顶部固定定位布局
1 布局基于angular ng-zorro组件库实现 由于项目中使用了组件库并且要求响应式布局,卡在这个坑上两天,多次调试后终于解决 代码仅供参考,由于没有上传依赖的库和组件包无法直接运行,提供代码 ...
- 理解CSS相对定位和固定定位
× 目录 [1]相对定位 [2]固定定位 前面的话 一般地,说起定位元素是指position不为static的元素,包括relative.absolute和fixed.前面已经详细介绍过absolut ...
- position之fixed固定定位、absolute绝对定位和relative相对定位
什么是层模型? 什么是层布局模型?层布局模型就像是图像软件PhotoShop中非常流行的图层编辑功能一样,每个图层能够精确定位操作,但在网页设计领域,由于网页大小的活动性,层布局没能受到热捧.但是在网 ...
- 解决ie6下不支持fix属性,模拟固定定位
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content ...
- Bootstrap 固定定位(Affix)
来自:慕课网 http://www.imooc.com/code/5396 Affix 效果常见的有以下三种: ☑ 顶部固定 ☑ 侧边栏固定 ☑ 底部固定 固定定位--声明式触发固定定位 Affix ...
- input固定定位后,当input框获取到焦点时,会离开手机软键盘的解决方法
前些天做页面时候遇到这样一个问题,将input框用position:fixed固定定位在最底部的时候,当Input获取焦点的时候,input框离开了手机软键盘,而不是吸附在软键盘上,效果如下图: 找了 ...
- 【CSS3】---层模型position之fixed固定定位、absolute绝对定位和relative相对定位
什么是层模型? 什么是层布局模型?层布局模型就像是图像软件PhotoShop中非常流行的图层编辑功能一样,每个图层能够精确定位操作,但在网页设计领域,由于网页大小的活动性,层布局没能受到热捧.但是在网 ...
随机推荐
- STM32F4通用定时器
1.基本原理 三种定时器区别 通用定时器功能特点描述 在这里只用输入捕获事件也能获取脉冲个数同时可以只使用它来获取脉冲宽度,比如当捕获到上升沿,马上进入中断,把计数器的值置零,然后等待捕获下降沿的到来 ...
- Oracle 更新Opatch、打补丁
1.更新Opatch; 2.打补丁; 3.grid 打补丁; 1.更新Opatch(实验版本:oracle:11.2.0.3.0): 默认安装数据库后,在ORACLE_HOME 下会有个OPatch ...
- 改善C#公共程序类库质量的10种方法(转)
出处:http://www.cnblogs.com/JamesLi2015/p/3140897.html 最近重构一套代码,运用以下几种方法,供参考. 1 公共方法尽可能的使用缓存 public s ...
- oracle11g客户端配置及使用(Instant Client)
http://www.oracle.com/technetwork/topics/winx64soft-089540.html http://www.cnblogs.com/ychellboy/a ...
- jQuary总结11:jQuery插件封装---jQuery封装 手风琴 动画插件
完整代码下载点击我的GitHub: https://github.com/XingJYGo/jquery-accordion 1 手风琴的效果展示如下: 2 封装插件目录结构如下: 主要包括:HTML ...
- UVALive 7749 Convex Contour (计算几何)
题意:给定上正方形,圆,三角形,让你求出包围它的最短的路径. 析:首先,如果是这种情况 三角形 三角形 三角形 正方形(圆) 三角形 三角形 三角形 ..这一种就是直接从左边直接连到正方形(圆),也 ...
- jsp乱码的问题
大家在JSP的开发过程中,经常出现中文乱码的问题,可能一至困扰着大家,现把JSP开发中遇到的中文乱码的问题及解决办法写出来供大家参考.首先了解一下Java中文问题的由来: Java的内核和class文 ...
- day 21 01 序列化模块和模块的导入的复习以及包的初识
day 21 01 序列化和模块的导入的复习以及包的初识 1.序列化模块 什么是序列化模块:数据类型转化成字符串的过程就是序列卷 为什么要使用序列化模块:为了方便存储和网络传输 三种序列化模块: (1 ...
- Linux 部署.Net Core 项目
前面也有说到,我学习Linux 主要因为要学习一下部署.NET CORE项目到Linux 系统,这里就记录一下部署的详细步骤吧. 主要需要安装以下几个工具 1..NET CORE SDK 2.Jexu ...
- Android Post方式发送信息和获取URL中的图片
需要Internet权限,AndroidManifest.xml <uses-permission android:name="android.permission.INTERNET& ...