韩顺平《轻松搞定网页设计HTML+CSS+JAVASCRIPT》之DIV+CSS学习笔记.doc
《韩顺平《轻松搞定网页设计HTML+CSS+JAVASCRIPT》之DIV+CSS学习笔记.doc》由会员分享,可在线阅读,更多相关《韩顺平《轻松搞定网页设计HTML+CSS+JAVASCRIPT》之DIV+CSS学习笔记.doc(33页珍藏版)》请在三一办公上搜索。
1、Div+css的讲解Div元素是用来为html文档内大块的内容提供结构和背景的元素。 CSS是英语cascading style sehhts的缩写(层叠样式表),他是一种用来表现HTML或XML等文件式样的计算机语言。Div+css是网站标准中常用的术语之一。 理解:1、Div是用来存放内容(文字,图片等其他元素)的容器( 元素)。2、Css用于说明DIV中的图片,文字或其他元素的样式(大小,颜色,背景,位置等)。 好处:1、html文件就会减少大量的table、tr、td,html变简单。2、solid green;.style1 table tdborder:1px solid yell
2、ow; Div+Css的发展三个历史时期: Table->table+css->div+css Css的必要性案例使用<span>元素,ide工具开发(myeclipe) <span style="font-size:40px; color:yellow;font:italic;">栏目二</span><br/> 从使用span元素我们可以看出,css的基本语法<元素名 style=”属性名:属性值;属性名2:属性值2;”/>元素可以是html的任意元素;属性名和属性值要参考帮助文档,w3c代码:<
3、;body> <span style="font-size:50px; color:blue;">栏目一</span><br/> <span style="font-size:40px; color:yellow;font:italic;">栏目二</span><br/> <span style="font-size:30px; color:red;font:normal;">栏目三</span><br/> <spa
4、n style="font-size:20px; color:green;font-weight:lighter;">栏目四<span style="font-size:10px; color:pink;font-weight:oblique;">栏目五</span><br/> </span><br/></body>使用css可以统一我们网站的风格。Css的分类:-><!- 引入 -><style type="text/css">
5、;.style1 </style></head> <body> /> <span style="font-size:50px; color:blue;">栏目一</span><br /> <span style="font-size:40px; color:yellow;font:italic;">栏目二</span><br font: 30px; color: green; font-weight: bold; font-style: norma
6、l; text-decoration: underline; <span style="font-size:30px; color:red;font:normal;">栏目三</span><br /> <span style="font-size:20px; color:green;font-weight:lighter;">栏目四<span style="font-size:10px; color:pink;font-weight:oblique;">栏目五<!- 下
7、面是是用控制 -> <span class="style1">苹果苹果苹果苹果苹果苹果</span> <span class="style1">西瓜西瓜西瓜西瓜西瓜西瓜</span> <span class="style1">香蕉香蕉香蕉香蕉香蕉香蕉</span> <span class="style1">花生花生花生花生花生花生</span> <br> <br> <br> &l
8、t;br> </span><br /> </span><br /> </body></html>统一了样式案例二Css滤镜的使用目的:1图片变成灰色,2、鼠标悬停恢复彩色1、 原图彩色 2、 使用滤镜后,灰色 3、 鼠标悬停 代码:<!DOCTYPE HTML PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN"> <html><head><title>test1l.html</title> <m
9、eta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"><meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style type="text/css"&
10、gt; /*使用滤镜 */ a:link img filter:gray; a:hover img filter:"" </style></head><body><a href="#"><img src="images/1.jpg" width="200"/></a><a href="#"><img src="images/2.jpg" width="200"/>
11、;</a><a href="#"><img src="images/3.jpg" width="200"/></a><a href="#"><img src="images/4.jpg" width="200"/></a></body></html>Css的三种选择器1、2、3、4、 类选择器 Id选择器 Html元素选择器 通配符选择器选择器就是在css中创建,而在网
12、页页面(html,jsp,.)中使用 类选择器 基本语法:.类选择器名属性名:属性值;1. 类选择器实例: HTML文件:<!DOCTYPE HTML PUBLIC "-/W3C/DTD HTML 4.01 Transitional/EN"> <html><head><title>xuanzeqi.html</title><meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <me
13、ta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" type="text/css" href="my.css"></head><body><span class
14、="style1">新闻一</span> <span class="style1">新闻二</span> <span class="style1">新闻三</span> <span class="style1">新闻四</span> <span class="style1">新闻五</span> </body></html> CSS文件:/*.style1 就
15、是类选择器*/.style1 font-weight: bold; font-size:20px; background-color: pink;ID选择器 基本用法:#id选择器名属性名:属性值; 实例: HTML文件<span id=style2>这是一个非常重要的新闻!</span>. CSS文件: /*#style2 就是一个id选择器*/#style2 font-size: 30px; background-color: silver; 在html文件中如果要引用id选择器,则: <元素 id=“id选择器的名称”>内容</元素名> H
16、TML选择器 基本语法:Html元素名属性名:属性值;实例: 代码:HTML文件:<body>你好北京!<span class="style1">新闻一</span><span class="style1">新闻二</span><span class="style1">新闻三</span><span class="style1">新闻四</span><span class="style1&qu
17、ot;>新闻五</span><br/><span id=style2>这是一个非常重要的新闻!</span></body>CSS文件:/*.style1 就是类选择器*/.style1 /*#style2 就是id选择器*/#style2 /*body 就是*/body color: orange; font-size: 30px; background-color: silver; color:black; color:black; font-weight: bold; font-size:20px; background-c
18、olor: pink; 结论:当一个元素被id选择器,类选择器,html选择器同时修饰,则优先级为:ID > 类 > HTML 课堂案例:我们希望所有的超链接:1、 默认样式是黑色,24px,没有下划线,2、 当鼠标移动到超链接时,自动出现下划线,3、 点击后,超链接变成红色。 代码:HTML文件:<body><a href="#">链接到搜狐</a><br/><a href="#">链接到新浪</a></body>CSS文件:a:link a:hover a
19、:VISITED color: red; text-decoration: underline; color=black; font-size: 24px; text-decoration: none;通配符选择器如果希望所有的元素都符合某一种样式,则可以使用通配符选择器 通配符基本语法:* Margin:0; padding:0 可以让所有的html元素的外边距和内边距都默认为0,有时候特别有用。实例: CSS文件代码:/*使用通配符选择器,作用是将外边距和内边距清0*/ * /*Margin:0px; */ /* margin-top: 10px; margin-left: 10px; m
20、argin-right: 0px; margin-bottom: 0px; */ margin:10px 0px 0px 10px;/*如果提供四个值,则这些值的顺序是从上外边距 (top) 开margin:10px 0px 0px;/*如果只提供三个值,则第一个值则为上,第二个用于左右,第margin:10px 15px;/*如果只提供两个值,则第一个值作用于上下,第二个用于左右 */ margin:10px;/*如果只提供一个值,则作用于四边*/ padding:0px;/*padding 规范与margin一样*/ 始围着元素顺时针旋转的:上-右-下-左 */ 三个用于下 */选择器的深
21、入讨论:1、 父子选择器案例: 使得“非常重要”四个字为红色斜体。方案:1、id选择器;2、CLASS选择器;3、父子选择器。 代码:HTML文件:<span id=style2>这是一个<span>非常重要</span>的新闻!</span><br/><br/> CSS文件:/*#style2 就是id选择器*/#style2 /*父子选择器*/#style2 span font-style: italic; color:red; font-size: 30px; background-color: silver; co
22、lor:black; 强调:1、子此处的标签(此处的span),必须为html可识别的;2、2、父子选择器可以向下继续扩展,可以有多级的。3、父子选择器可以适用于:ID选择器和类选择器。2、要求:“新闻一”红色,斜体 HTML 文件:<span class="style1" id="special">新闻一</span><span class="style1">新闻二</span>CSS文件:#special font-style: italic; color:red;结论:如果一个元素
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 轻松搞定网页设计HTML+CSS+JAVASCRIPT 顺平 轻松 搞定 网页 设计 HTML CSS JAVASCRIPT DIV 学习 笔记
![提示](https://www.31ppt.com/images/bang_tan.gif)
链接地址:https://www.31ppt.com/p-2881461.html