h5+c3

W3C盒子模型和ie盒子模型

文档加上的话,所有浏览器都按照W3C的盒子模型,否则ie会按照ie的盒子模型,它的content包括了padding border

box-sizing: content-box/border-box

text-shadow文字阴影

		/*
四个参数: x, y, blur(模糊程度) color
如果有多个阴影, 用逗号隔开
*/
text-shadow: -1px -1px 0px white, 1px 1px 0px black;

box-shadow盒子阴影

		/*
1. x, y, blur(模糊程度), 阴影的缩放, 内阴影或外阴影
2. 内外阴影只有一个参数inset,默认就是外阴影
*/
box-shadow: 0px 0px 10px 10px grey inset;//内阴影 box-shadow: 0px 0px 10px 10px grey; //外阴影

linear-gradient 线性渐变

/* 设置渐变 */
/* 默认从上往下发生渐变, 颜色是平均分布的 */
/* background: linear-gradient(red, yellow, steelblue, cyan); */
/* 可以在颜色后面设置颜色的百分比 */
/* background: linear-gradient(red 50%, yellow 70%, steelblue, cyan); */
/* 设置颜色的角度 */
/* background: linear-gradient(90deg,red, yellow, steelblue, cyan); */
background: linear-gradient(to bottom right, red , blue); /* 标准的语法

radial-gradient 径向渐变

/* linear: 线性的, radial: 径向的, gradient: 渐变, ellipse:椭圆 */
/* 半径写在at的前面, 超出半径的区域用最外面的颜色来填充 */
/* background: radial-gradient(100px at left bottom, red, yellow, steelblue); */ /* 直接指定圆心的坐标 */
/* 径向渐变的总结: 半径 at 圆心点, 颜色。。。 */
background: radial-gradient(100px at 20% 20%, red, yellow, steelblue);
/* 椭圆 */
background: radial-gradient(100px 50px at 20% 20% , red, yellow, steelblue);
background: radial-gradient(ellipse closest-side at 30px 50px, red, blue);

border-radius

/* 单独设置某个角: 如果设一个圆角,只需一个参数,如果设椭圆角,需要两个参数,中间用空格隔开 */
border-top-left-radius: 30px 60px;
/* 所有的x和所有的y 中间用 / 隔开*/
border-radius: 30px 30px 30px 30px/60px 60px 60px 60px;
/*复合写法,只写一, 二, 三对分别代表什么意思*/
/*如果只写一对参数: 对所有的解生效;写两对: 第一对对left,top和right, bottom生效,第二对对right top, left bottom生效;如果写三对, 第一对对left top生效, 第二对对right top, left bottom 生效, 第三对对 right bottom生效*/
border-radius: 30px 80px/ 60px 80px;

background-position & background-size

/* 如果需要设置背景图片的大小,必须指定其位置,大小永远写在位置的后面,用 / 隔开  */
background: url("./img/dog3.jpg") no-repeat center center;
/* 设置背景图片位置, 用得不是很多 */
background: url("./img/dog3.jpg") no-repeat 100px 100px/200px 150px;

多背景实现

background:
url("./img/bg1.png") no-repeat top left,
url("./img/bg2.png") no-repeat top right,
url("./img/bg4.png") no-repeat bottom left,
url("./img/bg3.png") no-repeat bottom right,
url("./img/fox2.jpg") no-repeat 112px 83px/365px 258px;
;

transform 变换

li:nth-child(2) {
/* 变换只会影响到当前元素,不会影响到其它元素, 在动画处理用得比较多 */
transform: scale(0.5);
} li:nth-child(3) {
transform: translate(100px, 200px)
} li:nth-child(4) {
transform: rotate(45deg);
} li:nth-child(5) {
transform: skew(45deg);
}

transform-origin 变换中心点

transform-origin: left top;

改变三个状态

transform: translate(1400px, -800px) scale(0.2) rotate(45deg);

transform-style 打开3d效果

/* 打开3d效果 */
transform-style: preserve-3d;

perspective 近大远小(父盒子)

如果要对某个元素实现近大远小的效果,就需要对其父元素设置perspective的属性, 越小, 效果越明显

perspective: 500px;

动画

/* 应用动画 */
/* forwards可以保存动画结束之后的状态 */
/* infinite 动画执行无限次 */ animation: name duration timing-function delay iteration-count direction; animation:rider-shake 0.5s 4, rider-go 4s 2s forwards; @keyframes rider-go {
/* from如果没有定义, 它就是初始状态,它就可以省略 */
from { } to {
transform: translateX(-1000px);
}
} @keyframes rider-shake {
/* 此句可以不写 */
0% {
/* 如果零秒是原始状态,可以不写 */
}
25% {
bottom: 21%;
} 75% {
bottom: 19%;
} /* 引句也可不写 */
100% {
/* 如果动画还原时和原始状态一致,也可以不写 */
}
}

分布执行动画

animation: changeBg 0.5s steps(11) infinite, swim 5s infinite forwards;

兼容ie8以下的h5写法

<!--[if lte IE 8]>
<script src="./js/html5shiv.js"></script>
<![endif]-->

操作类名

classList:

// 给某个元素添加一个类

document.body.classList.add("light");

// 移除某个元素的某个类

document.body.classList.remove("night");

// 切换类, 点一次删除, 再点一次添加, 轮换

document.body.classList.toggle("night");

// 判断是否拥有某个类

var isopen = document.body.classList.contains("light");

拖拽事件


<h3>从这个盒子</h3>
<div class="from">
<div class="move" draggable="true"></div>
</div>
<h3>到这个盒子</h3>
<div class="to"></div>

//添加和拖拽相关的事件
move.ondragstart = function() {
console.log("开始拖拽");
} move.ondrag = function() {
console.log("正在拖拽");
} move.ondragleave = function() {
console.log("离开");
} move.ondragend = function() {
console.log("结束拖拽");
} // 真正要实现的拖拽的效果,只需要实现这两个方法即可 // drop松手事件应该由将要被拖入的大盒子来监听 to.ondrop = function() {
console.log("松手");
to.appendChild(move);
} //要拖入的大盒子需要实现的方向
to.ondragover = function(event) {
// 阻止默认事件(默认是不允许拖入的)
event.preventDefault();
} to.ondragenter = function() {
console.log("进入盒子");
} // 如果要往回拖,那么from也需要设置为可以接收, 实现ondragover的事件, 阻止默认值
// drop松手事件应该由将要被拖入的大盒子来监听
from.ondrop = function() {
console.log("松手");
from.appendChild(move);
} //要拖入的大盒子需要实现的方向
from.ondragover = function(event) {
// 阻止默认事件(默认是不允许拖入的)
event.preventDefault();
}

拖拽进浏览器


// 如果想要拖入浏览器打开文件,必须要实现以下两个方法,并且,要阻止其默认事件
document.ondragover = function(event) {
event.preventDefault();
} document.ondrop = function(event) {
event.preventDefault();
} //如果想要拖到浏览器的小盒子里,那么必须把小盒子的默认事件阻止掉
var box = document.querySelector(".box"); box.ondragover = function(event) {
event.preventDefault();
} box.ondrop = function(event) {
event.preventDefault(); //就可以来读文件
var file = event.dataTransfer.files[0];
console.log(file); //创建一个filereader
var reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = function(){
alert("haha");
console.log(reader.result);
document.querySelector("img").setAttribute("src", reader.result);
}
}

FileReader

作用:实现上传预览

关键:files[0] FileReader reader.readAsDataURL() reader.onload reader.result


document.querySelector("#file").onchange = function(){
//1. 拿到file
var file = document.querySelector("#file").files[0];
//2. 创建fileReader
var reader = new FileReader();
//3. 加载并读取file
reader.readAsDataURL(file);
//4. 使用file
reader.onload = function() {
console.log(reader.result);
document.querySelector("img").setAttribute("src", reader.result);
}
}

本地存储

localStorage/sessionStorage 方法都一样


window.localStorage.setItem("myusername", name);
window.localStorage.getItem("myusername");
window.localStorage.clear();
window.localStorage.removeItem("myusername")

video

关键api

1.	video.pause()
2. video.play()
3. video.webkitRequestFullScreen() //全屏
4. video.currentTime //当前进度
5. video.duration //总进度

监听方法:

video.ontimeupdate = function(){  }

<video src="./movie/bglb.mp4"></video>

var video = document.querySelector("video"); //1. 判断是否是暂停状态
if (video.paused == true) {
//更换按钮
this.classList.remove("icon-play");
this.classList.add("icon-pause"); //播放
video.play();
} else { } //2. 全屏
video.webkitRequestFullScreen(); //3. 监听视频进度更新的事件
//视频的当前时间
("当前时间"+video.currentTime);
// 视频的总时间
//("总时间"+video.duration); video.ontimeupdate = function() {
var percent = video.currentTime/video.duration * 100 +"%";
console.log(percent); //给进度条添加样式
document.querySelector(".move").style.width = percent;
} //4. 点击进度条, 更改播放的位置
document.querySelector(".progress").onclick = function (event) {
//点击的x坐
var clickx = event.offsetX;
console.log(clickx);
//获取到progress的宽度
var pw = this.offsetWidth;
console.log(pw); var percent = clickx / pw;
// 当前的视频的时间点
var currentTime = percent * video.duration;
//设给video
video.currentTime = currentTime;
}

html5和css3的笔记的更多相关文章

  1. html5和css3学习笔记

    HTML5针对移动端,移动端的浏览器主要是chrome,是webkit内核; app(applicatin):应用; native app:原生的app sadsadsadad 单标签可以省略结尾标记 ...

  2. HTML5&CSS3读书笔记

    Hi All, 分享一下我学HTML5 摘抄的读书笔记(我用的还是英文,因为一些新的东西还是来自于欧美国家,希望大家习惯于看一些英文材料): 1. Difference between Section ...

  3. HTML5+CSS3学习笔记(一)

    HTML5+CSS3概述 HTML5和CSS3不仅仅是两项新的Web技术标准,更代表了下一代HTML和CSS技术.虽然HTML5的标准规范还没有正式发布,但是未来的发展前景已经可以预见,那就是HTML ...

  4. HTML5与CSS3基础教程第八版学习笔记11~15章

    第十一章,用CSS进行布局 开始布局注意事项 1.内容与显示分离 2.布局方法:固定宽度和响应式布局 固定宽度,整个页面和每一栏都有基于像素的宽度 响应式布局也称为流式页面,使用百分数定义宽度 3.浏 ...

  5. HTML5+CSS3学习笔记(一) 概述

    HTML5+CSS3概述      HTML5和CSS3不仅仅是两项新的Web技术标准,更代表了下一代HTML和CSS技术.虽然HTML5的标准规范还没有正式发布,但是未来的发展前景已经可以预见,那就 ...

  6. Web 前端开发精华文章推荐(jQuery、HTML5、CSS3)【系列十二】

    2012年12月12日,[<Web 前端开发人员和设计师必读文章>系列十二]和大家见面了.梦想天空博客关注 前端开发 技术,分享各种增强网站用户体验的 jQuery 插件,展示前沿的 HT ...

  7. Webix JavaScript UI 库可以帮你构建跨平台的HTML5 和 CSS3 程序

    XB 软件公司最近发布了JavaScript UI 库Webix ,其中包含的组件超过45个,用这些组件可以构建跟HTML5 和 CSS3 兼容的程序,这些程序不仅能在个人电脑上运行,还能用在iOS. ...

  8. 微信浏览器是移动端的IE6?微信升级内核后Html5和CSS3兼容性总结

    今年4月,自从微信浏览器X5 升级Blink内核之后,各前端社区一片高潮,仿佛看到了前端er,眼含热泪进而抱头痛头的说:终于可以不用兼容这"移动端的IE6 "了,可以早点回家了!! ...

  9. Web 前端开发精华文章集锦(jQuery、HTML5、CSS3)【系列十七】

    <Web 前端开发精华文章推荐>2013年第五期(总第十七期)和大家见面了.梦想天空博客关注 前端开发 技术,分享各种增强网站用户体验的 jQuery 插件,展示前沿的 HTML5 和 C ...

随机推荐

  1. Metadata

    元数据是关于数据的组织.数据域及其关系的信息,简言之,元数据就是关于数据的数据. Metadata is "data [information] that provides informat ...

  2. hadoop 安装问题总结

    安装启动步骤  [英语好的,直接手把手跟着来] http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-common/Sing ...

  3. 3D模型在UI上显示的方法(Unity)

    方法:使用RawImage通过Render Texter将摄像机下的物体渲染纹理记录并显示在RawImage上面 具体实现:新建一个模型(Cube),新建一个摄像机,将Clear Flags设置为So ...

  4. jsp 判断当前时间是否符合设置的时间条件

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  5. Codeforces Round #406 (Div. 2) 787-D. Legacy

    Rick and his co-workers have made a new radioactive formula and a lot of bad guys are after them. So ...

  6. vue 项目部署到nginx

    第一步在控制台终端输入npm run build 打包完成之后项目中会生成一个dist文件夹,直接访问里面的index.html就ok了 第二步配置nginx 第三步重启nginx service n ...

  7. 权值线段树&线段树合并

    权值线段树 所谓权值线段树,就是一种维护值而非下标的线段树,我个人倾向于称呼它为值域线段树. 举个栗子:对于一个给定的数组,普通线段树可以维护某个子数组中数的和,而权值线段树可以维护某个区间内数组元素 ...

  8. oracle到mysql的导数据方式(适用于任意数据源之间的互导)

    http://www.wfuyu.com/Internet/19955.html 为了生产库释放部份资源, 需要将API模块迁移到mysql中,及需要导数据. 尝试了oracle to mysql工具 ...

  9. 【ACM】poj_3981_字符串替换_201307271019

    字符串替换Time Limit: 1000MS  Memory Limit: 65536K Total Submissions: 8447  Accepted: 3988 Description 编写 ...

  10. Kafka的存储机制以及可靠性

    一.kafka的存储机制 kafka通过topic来分主题存放数据,主题内有分区,分区可以有多个副本,分区的内部还细分为若干个segment. 所谓的分区其实就是在kafka对应存储目录下创建的文件夹 ...