大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 网页设计 -> HTML/CSS -> css新手上路(5)

css新手上路(5)

时间: 2021-07-31 作者:daque

上一节发端咱们计划 css (cascading style sheet) 的普通. 报告你有三种 selector. 但只引见了个中的 html selector. 这一节咱们把三种都精细引见给你 html selector class selector: id selector: html selectorhtml selector 即是 html 的 tags, 比方 p, div, td 等. 如 你用 css 设置了它们, 在整页中, 这个 tag 的本质就依照你 的设置来表露了. html selector 的语法如次   tag {property:value}比方咱们想叫 h1 的脸色是红的   h1 {color: red}这边还要报告你 css 的一个特性, 它可设置好几个 selector 在一个 rule 里. 比方   h1, h2, td {color: red}这个设置就能让一切的 h1, h2, 和 td 的脸色都为赤色. class selectorclass selector 有两种, 一种叫关系 class selector, 它跟一 个 html 的 tag 相关系. 它的语法是   tag.classname {property:value}比方咱们想叫少许而不是十足 h2 的脸色是红的  h2.redone{color:red}

this is h2

this is red h2

this is h2this is red h2 第二种是独力 class selector . 它可被任何 html tag 所运用. 它的语法如次   .classname {property:value}假设咱们有底下这个设置   .blueone {color: blue}那么咱们不妨把他运用到各别的 tag 傍边去. 比方  .blueone{color:blue}

blue h2

blue paragraph

blue h2blue paragraph明显 class selector 给了咱们更多的自在. id selectorid selector 本来跟独力 class selector 的功效一律. 而辨别 在乎它们的语法和用法各别, 以及对于 javascript 安排 html 元素有扶助. 它的语法如次   #idname {property:value}假设咱们有底下的设置   #yelowone {color: yellow}咱们不妨应用这个设置就任何的有同样 id 名字的 tag, 比方  #redone{color:red}

  text here

text here你大概感触既是 id selector 和独力 class selector 功效一 样, 干什么两者都生存呢. 即使你领会用 css-p 来定位的话, 你就领会它们的辨别了. 有 id 的 html 元素不妨被 css-p 和 javascript 来安排 到此刻为止, 你仍旧大约领会怎样来写 css 的设置了, 底下 七节咱们将会报告你怎样用 css 来安排或窜改 字体 笔墨间的空间 列表 脸色 后台 margin 场所

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.