position

fixed:把标签固定在页面的某处

例子:使用fixed制作“回到顶部”按钮

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div onclick="GoTop();" style="width:50px;height:50px;background-color:black;color:white;
position:fixed;bottom:20px;right:20px">
返回顶部
</div>
<div style="height:5000px;background-color:#dddddd">
ddfdfdadfdf
</div>
<script>
function GoTop(){
document.documentElement.scrollTop = 0;
console.log(document.documentElement.scrollTop)
}
</script>
</body>
</html>

例子2:固定页面头部

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.pg-header{
height:48px;
background-color:black;
color:#dddddd;
position:fixed;
top:0;
right:0;
left:0;
}
.pg-body{
background-color:#dddddd;
height:5000px;
margin-top:50px;
}
</style>
</head>
<body>
<div class="pg-header">头部</div>
<div class="pg-body">内容</div>
</body>
</html>

absolute:把标签固定在页面的某处,位置是绝对固定的

relative:通常和absolute一起用

<div style='position:relative;'>
<div style='position:absolut;top:0,right:0;'></div>
<div/>

例子:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="width:50px;height:50px;
background-color:black;
position:absolute;
right:0;
bottom:0;"> </div>
<div style="margin:0 auto;position:relative;width:500px;height:200px;border:1px solid red;">
<div style="position:absolute;left:0;bottom:0;width:50px;height:50px;background-color:black;"></div>
</div>
<div style="margin:0 auto;position:relative;width:500px;height:200px;border:1px solid red;">
<div style="position:absolute;right:0;bottom:0;width:50px;height:50px;background-color:blue;"></div>
</div>
<div style="margin:0 auto;position:relative;width:500px;height:200px;border:1px solid red;">
<div style="position:absolute;right:0;top:0;width:50px;height:50px;background-color:blue;"></div>
</div> <div style="height:5000px;background-color:#dddddd;">
ddfdfdadfdf
</div>
</body>
</html>

页面分层显示:

z-index

opacity  透明 值:0-1

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="display:none;z-index:10;
position:fixed;background-color:white;
height:100px;
width:500px;
top:50%;
left:50%;
margin-left:-250px;margin-top:-200px; ">
<input type="text">
<input type="text">
<input type="text">
</div> <div style="display:none;z-index:9;position:fixed;background-color:#dddddd;
top:0;
bottom:0;
left:0;
right:0;
opacity:0.5;
"></div> <div style="height:5000px;background-color:green;">
ddfdfdadfdf
</div>
</body>
</html>

overflow

例子:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div style="height:200px;width:300px;overflow:hidden;">
<img src="IMG_1980.JPG">
</div>
<p></p>
<div style="height:200px;width:300px;overflow:auto;">
<img src="IMG_1980.JPG">
</div>
</body>
</html>

hover

鼠标移动到标签时,属性才生效

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
.pg-header{
position:fixed;
right:0;
left:0;
top:0;
height:48px;
background-color:#2459a2;
line-height:48px;
} .pg-body{
margin-top:50px;
} .w{
width:980px;
margin:0 auto;
} .pg-header .menu{
display:inline-block;
padding:0 10px 0 10px;
color:white;
} .pg-header .menu:hover{
background-color:blue;
}
</style>
</head>
<body>
<div class="pg-header">
<div class="w">
<a class="logo">LOGO</a>
<a class="menu">全部</a>
<a class="menu">42区</a>
<a class="menu">段子</a>
<a class="menu">1024</a>
</div>
</div>
<div class="pg-body">
<div class="w">g</div>
</div>
</body>
</html>

background-color  背景颜色

background-image:url('xxx.gif')#默认。div大,图片重复放  

background-repeat:no-repeat/repeat-x/repeat-y 图片重复加载

background-position:10px 10px/position-x/position-y 移动背景图片

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<span style="background-image:url('微笑.gif');height:20px;width:20px;display:inline-block;"></span>
<div style="height:35px;width:400px;position:relative;">
<input type="text" style="height:35px;width:370px;padding-right:30px" />
<span style="position:absolute;right:0;top:10px;background-image:url('微笑.gif');height:25px;width:25px;display:inline-block;"></span> </div> <div style="width:200px;height:200px;border:1px solid red;
background-image:url('土拨鼠.gif');
background-repeat:no-repeat;
background-position-x:10px;
background-position-y:10px"></div>
</body>
</html>

结束

html学习3-CSS补充的更多相关文章

  1. jQuery 顺便学习下CSS选择器 奇偶匹配nth-child(even)

    今天学习jQuery,看到nth-child(even)用法,特意找了下这个选择器的用法,在CSS3标准中,用法很强大. 对此,我把CSS3标准中nth-child()用法大致介绍下: CSS3伪类选 ...

  2. CSS补充与JavaScript基础

    一.CSS补充 position 1.fiexd 固定在页面的某个位置; 示例将顶部菜单始终固定在页面顶部 position: fixed; 将标签固定在某个位置 right: 0; 距离右边0像素 ...

  3. CSS补充之--页面布局、js补充,dom补充

    CSS补充之--页面布局 主站一:(下面是一个大致的模板) <div class="pg-header"> <div style="width: 120 ...

  4. css补充、JavaScript、Dom

    css补充: position: fixed:可以将标签固定在页面的某个位置 absolute+relative:通过两者的结合可以让标签在一个相对的位置 代码例子:(通过fixed标签将某些内容固定 ...

  5. 如何从零开始学习DIV+CSS

    CSS是样式,DIV是层.DIV+CSS是网站标准(web标准),通常为了说明与HTML网页设计语言中的表格(table)定位方式的区别.因为XHTML网站设计标准中,不再使用表格定位技术,而是采用D ...

  6. 学习完毕-css

    最近零零散散学习了css 最后附带链接,里面有css的全部demo.有空的可以练习练习,下一步 --->js -----http://www.w3cschool.cc/css/css-examp ...

  7. ReactNative学习之css样式使用

    前言: 前面学习了html,今天学习一下css的基本使用,看下html与css之间是如何结合来编写前端网页的. CSS 是什么? CSS 是 Cascading Style Sheets(级联样式表) ...

  8. Learning ROS for Robotics Programming Second Edition学习笔记(三) 补充 hector_slam

    中文译著已经出版,详情请参考:http://blog.csdn.net/ZhangRelay/article/category/6506865 Learning ROS for Robotics Pr ...

  9. HTML+CSS补充

    1. HTML+CSS补充 - 布局: <style> .w{ width:980px;margin:0 auto; } </style> <body> <d ...

  10. 2016.01.22 前端学习 HTML/CSS

    学习HTML/CSS  http://edu.51cto.com/course/course_id-3116.html 明日实践

随机推荐

  1. 《NVM-Express-1_4-2019.06.10-Ratified》学习笔记(8.21)-- Host Operation with Asymmetric Namespace Access Reporting

    8.21 使用ANA报告的主机操作 8.21.1 主机ANA普通操作 主机通过在Identify Controller数据结构中CMIC域的第3位来判断是否支持ANA.NSID或标识(参考第7.10章 ...

  2. Redis5-集群搭建实验

    集群规划: nodeA:192.168.29.22(22-master,23-slave) nodeB:192.168.29.23(23-master,24-slave) nodeC:192.168. ...

  3. 通过恢复目录(Catalogue)进行PDB级别的PITR恢复

    数据库版本:Oracle 12.2.0.1 本篇为<执行PDB的PITR恢复失败的说明 (文档 ID 2435452.1)>的证明篇,通过当前控制文件,无法在PDB级别进行PITR(Poi ...

  4. tomcat集群搭建集成nginx负载均衡

    软件基础+版本: 1.3台centos7系统,其中都已经配置完成了jdk环境,jdk的版本为 [root@node03 bin]# java -version java version "1 ...

  5. Python_装饰器函数

    楔子 作为一个会写函数的python开发,我们从今天开始要去公司上班了.写了一个函数,就交给其他开发用了. def func1(): print('in func1') 季度末,公司的领导要给大家发绩 ...

  6. 如何查看当前工程,已经安装的nuget包?

    本文链接:https://blog.csdn.net/Microsoft_Mao/article/details/101161872如果想知道,当前解决方案(solution)里都安装了什么包,这里可 ...

  7. Windows下PHP安装 Imagick 扩展

    1.下载拓展下载地址一: http://windows.php.net/downloads/pecl/releases/imagick/下载地址二: https://pecl.php.net/pack ...

  8. 后端工具——Maven——初篇——目录

    目录 Maven的知识体系包括四个部分.Maven的配置文件,Maven命令,Maven生命周期,Maven插件.在介绍Maven之前,首先需要介绍如何安装Maven. 安装:介绍Maven在Linu ...

  9. LED Decorative Light Supplier - Decorative Use Of LED Light Strips

    Led strip refers to the led assembly in the ribbon of the FPC (flexible circuit board) or PCB hard b ...

  10. AWS ec2的ubuntu14.04上安装git服务

    http://imerc.xyz/2015/11/13/Ubuntu-14-04%E4%B8%8AGit%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E6%90%AD%E5 ...