4-10固定定位
来源:互联网 发布:tp wifi访客网络 编辑:程序博客网 时间:2024/05/04 20:42
四、固定定位
固定定位就是相对浏览器窗口定位。无论页面如何滚动,这个盒子显示的位置不变(返回顶部按钮、导航栏)
固定定位会脱离标准文档流。
p{
width: 100px;
height: 100px;
background-color: orange;
position: fixed;
top: 100px;
left: 100px;
}
4.1 固定定位的用途:返回顶部按钮
.backtop{
position: fixed;
bottom: 100px;
right: 30px;
width: 60px;
height: 60px;
background-color: gray;
text-align: center;
line-height:30px;
color:white;
text-decoration: none;
}
<a class="backtop">返回<br />顶部</a>
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
4.2 固定定位的用途:顶部导航条的固定
* {
margin: 0;
padding: 0;
}
.nav {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 60px;
background-color: #333;
z-index: 99999999;
}
.inner_c {
width: 1000px;
height: 60px;
margin: 0 auto;
}
.inner_c ul {
list-style: none;
}
.inner_c ul li {
float: left;
width: 100px;
height: 60px;
text-align: center;
line-height: 60px;
}
.inner_c ul li a {
display: block;
width: 100px;
height: 60px;
color: white;
text-decoration: none;
}
.inner_c ul li a:hover {
background-color: gold;
}
<div class="nav">
<div class="inner_c">
<ul>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
<li><a href="#">网页栏目</a></li>
</ul>
</div>
</div>
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<img src="images/2.jpg" alt="" />
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Document</title> <style> p { width: 100px; height: 100px; background-color: orange; position: fixed; top: 100px; left: 100px; } </style></head><body> <p>阿萨德</p> <img src="images/0103-large.jpg" alt=""></body></html>
- 4-10固定定位
- 固定定位
- 固定定位
- 固定定位
- 固定定位
- 固定定位
- WebCore Rendering 4 - 绝对/固定定位和相对定位
- CSS定位之固定定位
- div固定定位
- 固定定位消息框
- 弹出框固定定位
- 06_05.固定定位
- 层模型--固定定位
- 固定定位fixed
- css的固定定位
- css固定定位
- 元素的固定定位
- 层模型--固定定位
- [LeetCode] Max Points on a Line
- 详解线上线下收单业务(1)
- 尺取法
- Linux基本操作及数据库查询
- Akka并发编程——第五节:Actor模型(四) 停止Actor
- 4-10固定定位
- linux系统644、755、777权限详解
- Java常识求阶层!的和 ,获取某个数组中的最小值,定义数组,获得成绩之和,平均成绩,最小成绩,最大成绩。等问题大全
- Revit二次开发——revit怎么给桥梁加钢筋
- rescue(BFS+优先队列)
- Linux常用功能
- 进程间通信(一)-----管道
- 高等数学图形与动画
- JVM笔记整理(第6章)