网站大量收购独家精品文档,联系QQ:2885784924

CSS基础知识(用例子来讲解).ppt

  1. 1、本文档共57页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
CSS基础知识(用例子来讲解)

小结: 在网页上应用CSS的三种方法: 行内样式 (Inline Styles) 内部样式表(Embedding a Style Block) 外部样式表(Linking to a Style Sheet) 内部样式表优于行内样式。 外部样式表优于内部样式表。 CSS 样式由“选择器”和“声明”组成。 声明由“属性”和“属性值”组成。 每条声明之间用“;” 分隔。 三、CSS 基本语法 selectors { property: value; } 选择器 属性 属性值 声明 四、CSS 选择器 CSS 常用选择器的类型: 通配选择器 类型选择器 类选择器 ID 选择器 后代选择器 伪类 群选择器 四、CSS 选择器 1. 通配选择器( Universal Selector ) * { property: value; } 例: * { padding: 0; margin: 0; } 四、CSS 选择器 2. 类型选择器( Type Selectors ) Tag { property: value; } 例: body { font: 0.75em/1.5 宋体; background: #E0E0E0 url(images/bg.gif); } h1 { font-size: 180%; margin: 1em 0; } p { margin: 1em 0; } 四、CSS 选择器 3. ID 选择器( ID Selectors ) #ID { property: value; } 例: #container { width: 760px; margin: auto; } #header { height: 120px; background: url(images/bg_header.gif) no-repeat; } #content { padding: 30px; } 四、CSS 选择器 5. 类选择器( Class Selectors ) .className { property: value; } 使用类选择器需要两个步骤: 标识类; 定义类。 四、CSS 选择器 5. 类选择器( Class Selectors ) 例: head title散文诗 /title /head body h2《秋夜》/h2 p鲁迅/p p在我的后园,可以看见墙外有两株树,……/p /body h2 class=“center”《秋夜》/h2 p鲁迅/p h2 class=“center”《秋夜》/h2 p class=“center” 鲁迅/p style type=text/css .center { text-align: center; } /style /head body h2 class=“center”《秋夜》/h2 p class=“center” 鲁迅/p p在我的后园,可以看见墙外有两株树,……/p /body style type=text/css .center { text-align: center; } h2.center { color: #0000FF; } /style /head body h2 class=“center”《秋夜》/h2 p class=“center” 鲁迅/p p在我的后园,可以看见墙外有两株树,……/p /body 四、CSS 选择器 4. 后代选择器( Descendant Selectors ) selector1 selector2 { property: value } 说明:选择所有被 selector1 包含的 selector2。 例: #content p { text-indent: 2em; } 四、CSS 选择器 4. 子选择器 selector1selector2 { property: value } 说明:选择selector1的第一代元素selector2。 例: .foodli { text-indent: 2em; } 四、CSS 选择器 7. 伪类( Pseudo-Classes Selectors ) selector : pseudo-class { property: value } 例: a:link { color: #000000; text-decoration: none

文档评论(0)

a888118a + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档