一.CSS与HTML 总结
css
作用: 用来美化页面
0、语法(使用规则)
1、先找到元素 (选择器)
2、设定什么(属性名), 设定成什么(属性值)
选择器:
* --> 通用选择器
元素选择器
#id
.class
[id] [id=idv]
, 分组选择器
选择器1 选择器2 后代选择
选择器1 > 选择器2 子代代选择
+ ~
====================================================================================
HTML
表单 form
method:get/post
action:url
input type
submit -> 提交按钮
image -> 具有提交功能
reset -> 重置按钮
text -> 普通文本输入框 value
password -> 密码框
radio -> 单选框 (同一组的name 属性要一致)on value
checkbox -> 复选框(同一组的name 属性要一致)on value
file -> 文件 在form表单中假如enctyp=multipart/form-data
button -> 普通按钮
hidden -> 隐藏域 不会显示在页面
select -> 下拉列表 name
option -> 下拉选项 value
textarea -> 文本域
button -> 具有提交功能
注意:表单项需要将值传入后台, 必须要有name属性
通用属性:
id
name
class
style
value -> 传输的数据
CSS
作用:美化页面, 精确地给某个|某些元素加特定的样式(背景、文本、大小、位置、风格)
1、基本语法
选择器{属性名称:属性值;}
2、三种使用方式(css 不能脱离html独自存在显现效果)
style 属性
style 标签
link css文件
3、选择器
*
div
#id
.className
[name] | [name=value]
选择器1, 选择器2
选择器1 选择器2
选择器1 > 选择器2
选择器1 +选择器2
选择器1 ~ 选择器2
4、常用属性
背景 background-color|background-mage:url(路径)
文本样式: 颜色 大小 字体
5、盒子模型 (看某个元素所占的实际的空间)
二.CSS,HTML,JS小结
HTML -> 网页的整体结构(内容)
CSS -> 对网页的美化 (必须要有网页才有效果)
JS -> 让网页动起来 (必须要有网页才有效果)
工具-> 使用浏览器进行解析, 才能有效果
JavaScript包含3部分
1、基础语法 ECMAScript ***
2、文档对象模型DOM ***
3、浏览器对象模型BOM
1、js是一门弱类型语言
变量不区分类型 var
数据本身是有类型的 10 'abc' true
0)、变量声明使用关键字 var
1)、可以只声明 , 不赋值 undefined
2)、如果没有声明, 直接使用, 报错 not defined
3)、重复定义时,没有问题, 如果没有赋值,则保留原值,如果再次赋值,则进行覆盖
4)、变量没有类型,里边可以存储任意值
三.JS的三种使用方式
1、行内式 : 写在元素中, 通过属性来添加
2、嵌入式: 添加一个javascript标签, 来代表js代码区域
3、引入式:单独写出一个js文件, 通过script标签来引入
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>js介绍</title>
<!--js的使用方式 3种
1、行内式 : 写在元素中, 通过属性来添加
2、嵌入式: 添加一个javascript标签, 来代表js代码区域
3、引入式:单独写出一个js文件, 通过script标签来引入
-->
<!--<script type="text/javascript">
alert("你好啊,世界");
</script>-->
<script type="text/javascript" src="js/test.js" ></script>
/*
test.js只需要写一条输出语句就可以
*/
</head>
<body>
<button onclick="alert('hello world');">按钮</button>
</body>
</html>
四.JS小测
1.数据类型
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>数据类型</title>
<script type="text/javascript">
/*js数据类型 typeof 来检验*/
// 验证某个数据是什么类型, 验证某个变量中存储的数据是什么类型
var box = null;
// null 本身是一种类型, null , 但是使用typeof 验证出来的字符串为 "object"
//var t = typeof box;
console.log(typeof box)
// 函数本身不是一种数据类型, 属于object的, 但是使用 typeof 检验的结果字符串为 “function”
function test(){ }
console.log(typeof test);
console.log("========================");
// undefined
// 1、什么时候会出现undefined
// 1)、只声明没赋值的变量, 默认为undefined
// 2)、显示赋值为 undefined
// 3)、定义函数时存在形参,而没有在调用时传入实参, 此时使用的参数为 undefined。
// 4)、当一个函数定义时,没有return出值, 但是使用变量来接收, 会得到undefined。
// 2、使用 typeof来验证 undefined时 , 会出现什么类型
var box1 ;
console.log(box1)
console.log(typeof box1)
var box2 = undefined;
console.log(box2)
console.log(typeof box2)
console.log(typeof undefined)
function test(a){
/*console.log(a);*/
/*return 10;*/
}
var temp = test();
console.log(temp);
console.log("=============================")
var box3 = true;
var box4 = false;
console.log(box3 + "=====" + typeof box3);
console.log(box4 + "=====" + typeof box4);
console.log("=============================")
var box5 = "abc";
box5 = 'eee';
box5 = 'true';
console.log(box5 + "===" + typeof box5);
console.log("=============================")
var box6 = 1.3;
console.log(box6 + "===" + typeof box6);
var box7 = {};
console.log(typeof box7)
box7 = [];
console.log(typeof box7)
var box8 = null;
var box9;
/*alert(box8==box9)*/
box9 = 1.0;
console.log(box9)
</script>
</head>
<body>
</body>
</html>
2.特殊字符
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>数据类型</title>
<script type="text/javascript">
/*js数据类型 typeof 来检验*/
// 验证某个数据是什么类型, 验证某个变量中存储的数据是什么类型
var box = null;
// null 本身是一种类型, null , 但是使用typeof 验证出来的字符串为 "object"
//var t = typeof box;
console.log(typeof box)
// 函数本身不是一种数据类型, 属于object的, 但是使用 typeof 检验的结果字符串为 “function”
function test(){ }
console.log(typeof test);
console.log("========================");
// undefined
// 1、什么时候会出现undefined
// 1)、只声明没赋值的变量, 默认为undefined
// 2)、显示赋值为 undefined
// 3)、定义函数时存在形参,而没有在调用时传入实参, 此时使用的参数为 undefined。
// 4)、当一个函数定义时,没有return出值, 但是使用变量来接收, 会得到undefined。
// 2、使用 typeof来验证 undefined时 , 会出现什么类型
var box1 ;
console.log(box1)
console.log(typeof box1)
var box2 = undefined;
console.log(box2)
console.log(typeof box2)
console.log(typeof undefined)
function test(a){
/*console.log(a);*/
/*return 10;*/
}
var temp = test();
console.log(temp);
console.log("=============================")
var box3 = true;
var box4 = false;
console.log(box3 + "=====" + typeof box3);
console.log(box4 + "=====" + typeof box4);
console.log("=============================")
var box5 = "abc";
box5 = 'eee';
box5 = 'true';
console.log(box5 + "===" + typeof box5);
console.log("=============================")
var box6 = 1.3;
console.log(box6 + "===" + typeof box6);
var box7 = {};
console.log(typeof box7)
box7 = [];
console.log(typeof box7)
var box8 = null;
var box9;
/*alert(box8==box9)*/
box9 = 1.0;
console.log(box9)
</script>
</head>
<body>
</body>
</html>
3.类型转换
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
var box;
console.log("===="+box);
console.log(box+1);
var box1 = NaN+1;
console.log(box1);
if(box){
console.log("undefined->boolean->true")
}else{
console.log("undefined->boolean->false")
}
if("1.5"){
console.log("能不能看见我")
}
console.log("=================================")
console.log(parseInt("11",36))
console.log(parseFloat("0xA"))
console.log(parseFloat("0809"))
console.log("=================================")
var data = 10
console.log(data.toString())
console.log(data.toString(2))
data = 1.45;
console.log(data.toFixed(3));
data = true
console.log(data.toString())
/*data = undefined;
console.log(data.toString())*/
console.log(Boolean(Infinity));
// 将其他数据转为字符串
var t = null;
console.log(t.toString());
console.log(String(t));
// 数字 字符串 Boolean
</script>
</head>
<body>
</body>
</html>